#[cfg(feature = "std")]
extern crate std;
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[repr(transparent)]
pub struct Error(pub i32);
impl Error {
#[inline(always)]
pub const fn new(raw: i32) -> Self {
Self(raw)
}
#[cfg(feature = "std")]
#[inline(always)]
pub fn into_std_io_error(self) -> std::io::Error {
std::io::Error::from_raw_os_error(self.0)
}
}
impl From<i32> for Error {
#[inline(always)]
fn from(value: i32) -> Self {
Self::new(value)
}
}
impl From<linux_unsafe::result::Error> for Error {
#[inline(always)]
fn from(value: linux_unsafe::result::Error) -> Self {
Self::new(value.0)
}
}
impl Into<core::fmt::Error> for Error {
#[inline(always)]
fn into(self) -> core::fmt::Error {
core::fmt::Error
}
}
#[cfg(feature = "std")]
impl Into<std::io::Error> for Error {
#[inline(always)]
fn into(self) -> std::io::Error {
self.into_std_io_error()
}
}
linux_unsafe::result::errno_derived_consts!(Error, Error);