Use NotSupported in more places

This commit is contained in:
Christiaan Dirkx 2021-02-26 00:17:36 +01:00
parent 86592b9939
commit 1b5f117c47
6 changed files with 48 additions and 47 deletions

View file

@ -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()
}
}

View file

@ -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",
)
}

View file

@ -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()
}
}

View file

@ -50,7 +50,7 @@ pub fn unsupported<T>() -> crate::io::Result<T> {
}
pub fn unsupported_err() -> crate::io::Error {
crate::io::Error::new_const(ErrorKind::Other, &"operation not supported on SGX yet")
crate::io::Error::new_const(ErrorKind::NotSupported, &"operation not supported on SGX yet")
}
/// This function is used to implement various functions that doesn't exist,

View file

@ -366,7 +366,7 @@ impl FileAttr {
}
Err(io::Error::new_const(
io::ErrorKind::Other,
io::ErrorKind::NotSupported,
&"creation time is not available on this platform \
currently",
))

View file

@ -447,7 +447,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
#[cfg(any(target_os = "fuchsia", target_os = "l4re"))]
pub fn current_exe() -> io::Result<PathBuf> {
use crate::io::ErrorKind;
Err(io::Error::new_const(ErrorKind::Other, &"Not yet implemented!"))
Err(io::Error::new_const(ErrorKind::NotSupported, &"Not yet implemented!"))
}
#[cfg(target_os = "vxworks")]