1
Fork 0

Add and insta-stabilize std::io::ErrorKind::NotSupported

This commit is contained in:
Christiaan Dirkx 2020-11-20 06:14:29 +01:00
commit 4a15bd8eaf
6 changed files with 11 additions and 6 deletions

View file

@ -180,6 +180,10 @@ pub enum ErrorKind {
/// read. /// read.
#[stable(feature = "read_exact", since = "1.6.0")] #[stable(feature = "read_exact", since = "1.6.0")]
UnexpectedEof, UnexpectedEof,
/// This operation is not supported on this platform.
#[stable(feature = "not_supported_error", since = "1.50.0")]
NotSupported,
} }
impl ErrorKind { impl ErrorKind {
@ -203,6 +207,7 @@ impl ErrorKind {
ErrorKind::Interrupted => "operation interrupted", ErrorKind::Interrupted => "operation interrupted",
ErrorKind::Other => "other os error", ErrorKind::Other => "other os error",
ErrorKind::UnexpectedEof => "unexpected end of file", ErrorKind::UnexpectedEof => "unexpected end of file",
ErrorKind::NotSupported => "not supported",
} }
} }
} }

View file

@ -1,6 +1,6 @@
macro_rules! unimpl { macro_rules! unimpl {
() => { () => {
return Err(io::Error::new_const(io::ErrorKind::Other, &"No networking available on L4Re.")); return Err(io::Error::new_const(io::ErrorKind::NotSupported, &"No networking available on L4Re."));
}; };
} }

View file

@ -18,7 +18,7 @@ pub fn unsupported<T>() -> std_io::Result<T> {
} }
pub fn unsupported_err() -> std_io::Error { pub fn unsupported_err() -> std_io::Error {
std_io::Error::new_const(std_io::ErrorKind::Other, &"operation not supported on this platform") std_io::Error::new_const(std_io::ErrorKind::NotSupported, &"operation not supported on this platform")
} }
pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind { pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind {

View file

@ -80,11 +80,11 @@ pub fn getenv(_: &OsStr) -> io::Result<Option<OsString>> {
} }
pub fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> { pub fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> {
Err(io::Error::new_const(io::ErrorKind::Other, &"cannot set env vars on this platform")) Err(io::Error::new_const(io::ErrorKind::NotSupported, &"cannot set env vars on this platform"))
} }
pub fn unsetenv(_: &OsStr) -> io::Result<()> { pub fn unsetenv(_: &OsStr) -> io::Result<()> {
Err(io::Error::new_const(io::ErrorKind::Other, &"cannot unset env vars on this platform")) Err(io::Error::new_const(io::ErrorKind::NotSupported, &"cannot unset env vars on this platform"))
} }
pub fn temp_dir() -> PathBuf { pub fn temp_dir() -> PathBuf {

View file

@ -802,7 +802,7 @@ pub fn link(original: &Path, link: &Path) -> io::Result<()> {
#[cfg(target_vendor = "uwp")] #[cfg(target_vendor = "uwp")]
pub fn link(_original: &Path, _link: &Path) -> io::Result<()> { pub fn link(_original: &Path, _link: &Path) -> io::Result<()> {
return Err(io::Error::new_const(io::ErrorKind::Other, &"hard link are not supported on UWP")); return Err(io::Error::new_const(io::ErrorKind::NotSupported, &"hard link are not supported on UWP"));
} }
pub fn stat(path: &Path) -> io::Result<FileAttr> { pub fn stat(path: &Path) -> io::Result<FileAttr> {

View file

@ -370,7 +370,7 @@ impl Socket {
#[cfg(target_vendor = "uwp")] #[cfg(target_vendor = "uwp")]
fn set_no_inherit(&self) -> io::Result<()> { fn set_no_inherit(&self) -> io::Result<()> {
Err(io::Error::new_const(io::ErrorKind::Other, &"Unavailable on UWP")) Err(io::Error::new_const(io::ErrorKind::NotSupported, &"Unavailable on UWP"))
} }
pub fn shutdown(&self, how: Shutdown) -> io::Result<()> { pub fn shutdown(&self, how: Shutdown) -> io::Result<()> {