use super::RawOsError;
pub trait ErrorKind: core::fmt::Debug + core::fmt::Display + Copy {
const OTHER: Self;
fn uncategorized() -> Self;
}
pub trait FromRawOsError: ErrorKind {
fn from_raw_os_error(raw: RawOsError) -> Self;
}
#[cfg(feature = "std")]
pub trait FromIoKind: ErrorKind {
fn from_io_error_kind(kind: std::io::ErrorKind) -> Self;
}
#[cfg(feature = "std")]
pub trait IntoIoKind: ErrorKind {
fn into_io_error_kind(self) -> std::io::ErrorKind;
}
#[cfg(feature = "std")]
mod std_impls {
use super::*;
impl ErrorKind for std::io::ErrorKind {
const OTHER: Self = Self::Other;
fn uncategorized() -> Self {
Self::Other }
}
impl FromIoKind for std::io::ErrorKind {
fn from_io_error_kind(kind: std::io::ErrorKind) -> Self {
kind
}
}
impl IntoIoKind for std::io::ErrorKind {
fn into_io_error_kind(self) -> std::io::ErrorKind {
self
}
}
impl FromRawOsError for std::io::ErrorKind {
fn from_raw_os_error(raw: RawOsError) -> Self {
std::io::Error::from_raw_os_error(raw).kind() }
}
}