pub struct Error { /* private fields */ }
Expand description
Implementations§
Source§impl Error
impl Error
Sourcepub fn kernel(op: Operation, code: KernelCode) -> Self
pub fn kernel(op: Operation, code: KernelCode) -> Self
Returns an error that wraps a system_error::KernelCode
along with an Operation
.
§Examples
use vmap::{Error, Operation};
println!("Kernel error: {:?}", Error::kernel(
Operation::RingAllocate,
1,
));
Sourcepub fn last_os_error(op: Operation) -> Self
pub fn last_os_error(op: Operation) -> Self
Returns an error representing the last OS error which occurred.
This function reads the value of errno
for the target platform (e.g.
GetLastError
on Windows) and will return a corresponding instance of
Error
for the error code.
§Examples
use vmap::{Error, Operation};
println!("last OS error: {:?}", Error::last_os_error(Operation::MapFile));
Sourcepub fn raw_os_error(&self) -> Option<i32>
pub fn raw_os_error(&self) -> Option<i32>
Returns the OS error that this error represents (if any).
If this Error
was constructed via last_os_error
, then this function
will return Some
, otherwise it will return None
.
§Examples
use vmap::{Error, Input, Operation};
fn print_os_error(err: &Error) {
if let Some(raw_os_err) = err.raw_os_error() {
println!("raw OS error: {:?}", raw_os_err);
} else {
println!("Not an OS error");
}
}
// Will print "raw OS error: ...".
print_os_error(&Error::last_os_error(Operation::MapFile));
// Will print "Not an OS error".
print_os_error(&Error::input(Operation::MapFile, Input::InvalidRange));
Sourcepub fn kind(&self) -> ErrorKind
pub fn kind(&self) -> ErrorKind
Returns the corresponding std::io::ErrorKind
for this error.
§Examples
use std::io::ErrorKind;
use vmap::{Error, Operation};
fn print_error(err: Error) {
println!("{:?}", err.kind());
}
// Will print "Other".
print_error(Error::last_os_error(Operation::MapFile));
// Will print "NotFound".
print_error(Error::io(Operation::MapFile, ErrorKind::NotFound.into()));
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more