Hide Repr details from io::Error, and rework io::Error::new_const
.
This commit is contained in:
parent
71226d717a
commit
554918e311
49 changed files with 345 additions and 269 deletions
|
@ -154,9 +154,9 @@ impl Socket {
|
|||
let mut pollfd = libc::pollfd { fd: self.as_raw_fd(), events: libc::POLLOUT, revents: 0 };
|
||||
|
||||
if timeout.as_secs() == 0 && timeout.subsec_nanos() == 0 {
|
||||
return Err(io::Error::new_const(
|
||||
return Err(io::const_io_error!(
|
||||
io::ErrorKind::InvalidInput,
|
||||
&"cannot set a 0 duration timeout",
|
||||
"cannot set a 0 duration timeout",
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ impl Socket {
|
|||
loop {
|
||||
let elapsed = start.elapsed();
|
||||
if elapsed >= timeout {
|
||||
return Err(io::Error::new_const(io::ErrorKind::TimedOut, &"connection timed out"));
|
||||
return Err(io::const_io_error!(io::ErrorKind::TimedOut, "connection timed out"));
|
||||
}
|
||||
|
||||
let timeout = timeout - elapsed;
|
||||
|
@ -192,9 +192,9 @@ impl Socket {
|
|||
// for POLLHUP rather than read readiness
|
||||
if pollfd.revents & libc::POLLHUP != 0 {
|
||||
let e = self.take_error()?.unwrap_or_else(|| {
|
||||
io::Error::new_const(
|
||||
io::const_io_error!(
|
||||
io::ErrorKind::Uncategorized,
|
||||
&"no error set after POLLHUP",
|
||||
"no error set after POLLHUP",
|
||||
)
|
||||
});
|
||||
return Err(e);
|
||||
|
@ -338,9 +338,9 @@ impl Socket {
|
|||
let timeout = match dur {
|
||||
Some(dur) => {
|
||||
if dur.as_secs() == 0 && dur.subsec_nanos() == 0 {
|
||||
return Err(io::Error::new_const(
|
||||
return Err(io::const_io_error!(
|
||||
io::ErrorKind::InvalidInput,
|
||||
&"cannot set a 0 duration timeout",
|
||||
"cannot set a 0 duration timeout",
|
||||
));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue