autocommit 2022-03-11 18:15:21 CET
This commit is contained in:
parent
0399772467
commit
b1890894b2
30 changed files with 2909 additions and 504 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use once_cell::sync::Lazy;
|
||||
use std::error::Error;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use uapi::c::c_int;
|
||||
use uapi::{c, Errno};
|
||||
|
||||
static ERRORS: Lazy<&'static [Option<&'static str>]> = Lazy::new(|| {
|
||||
|
|
@ -168,6 +169,21 @@ impl From<Errno> for OsError {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<c::c_int> for OsError {
|
||||
fn from(v: c_int) -> Self {
|
||||
Self(v)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for OsError {
|
||||
fn from(v: std::io::Error) -> Self {
|
||||
match v.raw_os_error() {
|
||||
Some(v) => Self(v),
|
||||
None => Self(c::EINVAL),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for OsError {}
|
||||
|
||||
impl Display for OsError {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue