diff options
| author | Christiaan Dirkx <christiaan@dirkx.email> | 2021-02-26 00:17:36 +0100 |
|---|---|---|
| committer | Christiaan Dirkx <christiaan@dirkx.email> | 2021-04-18 09:29:23 +0200 |
| commit | 1b5f117c47dcc1b041c686d4c6016ebf96006f06 (patch) | |
| tree | 80a8ada421842f8bbaa819380eb4b36827c4f221 /library/std/src/sys/hermit | |
| parent | 86592b9939df4e5534ea37cda6bc0b7f7ca8b70e (diff) | |
| download | rust-1b5f117c47dcc1b041c686d4c6016ebf96006f06.tar.gz rust-1b5f117c47dcc1b041c686d4c6016ebf96006f06.zip | |
Use `NotSupported` in more places
Diffstat (limited to 'library/std/src/sys/hermit')
| -rw-r--r-- | library/std/src/sys/hermit/fd.rs | 9 | ||||
| -rw-r--r-- | library/std/src/sys/hermit/mod.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/hermit/net.rs | 78 |
3 files changed, 45 insertions, 44 deletions
diff --git a/library/std/src/sys/hermit/fd.rs b/library/std/src/sys/hermit/fd.rs index 1c0515a1503..c400f5f2c2e 100644 --- a/library/std/src/sys/hermit/fd.rs +++ b/library/std/src/sys/hermit/fd.rs @@ -1,9 +1,10 @@ #![unstable(reason = "not public", issue = "none", feature = "fd")] -use crate::io::{self, ErrorKind, Read}; +use crate::io::{self, Read}; use crate::mem; use crate::sys::cvt; use crate::sys::hermit::abi; +use crate::sys::unsupported; use crate::sys_common::AsInner; #[derive(Debug)] @@ -46,7 +47,7 @@ impl FileDesc { self.duplicate_path(&[]) } pub fn duplicate_path(&self, _path: &[u8]) -> io::Result<FileDesc> { - Err(io::Error::new_const(ErrorKind::Other, &"duplicate isn't supported")) + unsupported() } pub fn nonblocking(&self) -> io::Result<bool> { @@ -54,11 +55,11 @@ impl FileDesc { } pub fn set_cloexec(&self) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"cloexec isn't supported")) + unsupported() } pub fn set_nonblocking(&self, _nonblocking: bool) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"nonblocking isn't supported")) + unsupported() } } diff --git a/library/std/src/sys/hermit/mod.rs b/library/std/src/sys/hermit/mod.rs index 1ecda25c03d..1fa929e48db 100644 --- a/library/std/src/sys/hermit/mod.rs +++ b/library/std/src/sys/hermit/mod.rs @@ -56,7 +56,7 @@ pub fn unsupported<T>() -> crate::io::Result<T> { pub fn unsupported_err() -> crate::io::Error { crate::io::Error::new_const( - crate::io::ErrorKind::Other, + crate::io::ErrorKind::NotSupported, &"operation not supported on HermitCore yet", ) } diff --git a/library/std/src/sys/hermit/net.rs b/library/std/src/sys/hermit/net.rs index 7053487ccfb..a9c09b6ceef 100644 --- a/library/std/src/sys/hermit/net.rs +++ b/library/std/src/sys/hermit/net.rs @@ -166,7 +166,7 @@ impl TcpStream { } pub fn socket_addr(&self) -> io::Result<SocketAddr> { - Err(io::Error::new_const(ErrorKind::Other, &"socket_addr isn't supported")) + unsupported() } pub fn shutdown(&self, how: Shutdown) -> io::Result<()> { @@ -199,7 +199,7 @@ impl TcpStream { } pub fn take_error(&self) -> io::Result<Option<io::Error>> { - Err(io::Error::new_const(ErrorKind::Other, &"take_error isn't supported")) + unsupported() } pub fn set_nonblocking(&self, mode: bool) -> io::Result<()> { @@ -247,27 +247,27 @@ impl TcpListener { } pub fn set_ttl(&self, _: u32) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn ttl(&self) -> io::Result<u32> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn set_only_v6(&self, _: bool) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn only_v6(&self) -> io::Result<bool> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn take_error(&self) -> io::Result<Option<io::Error>> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } } @@ -281,127 +281,127 @@ pub struct UdpSocket(abi::Handle); impl UdpSocket { pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<UdpSocket> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn peer_addr(&self) -> io::Result<SocketAddr> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn socket_addr(&self) -> io::Result<SocketAddr> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn send_to(&self, _: &[u8], _: &SocketAddr) -> io::Result<usize> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn duplicate(&self) -> io::Result<UdpSocket> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn set_write_timeout(&self, _: Option<Duration>) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn read_timeout(&self) -> io::Result<Option<Duration>> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn write_timeout(&self) -> io::Result<Option<Duration>> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn set_broadcast(&self, _: bool) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn broadcast(&self) -> io::Result<bool> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn set_multicast_loop_v4(&self, _: bool) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn multicast_loop_v4(&self) -> io::Result<bool> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn set_multicast_ttl_v4(&self, _: u32) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn multicast_ttl_v4(&self) -> io::Result<u32> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn set_multicast_loop_v6(&self, _: bool) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn multicast_loop_v6(&self) -> io::Result<bool> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn set_ttl(&self, _: u32) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn ttl(&self) -> io::Result<u32> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn take_error(&self) -> io::Result<Option<io::Error>> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn recv(&self, _: &mut [u8]) -> io::Result<usize> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn send(&self, _: &[u8]) -> io::Result<usize> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } pub fn connect(&self, _: io::Result<&SocketAddr>) -> io::Result<()> { - Err(io::Error::new_const(ErrorKind::Other, &"not supported")) + unsupported() } } |
