Struct vmm_sys_util::errno::Error [−][src]
pub struct Error(_);Expand description
Wrapper over errno.
The error number is an integer number set by system calls and some libc functions in case of error.
Implementations
Returns the last occurred errno wrapped in an Error.
Calling Error::last() is the equivalent of using
errno in C/C++.
The result of this function only has meaning after a libc call or syscall
where errno was set.
Examples
extern crate vmm_sys_util;
use vmm_sys_util::errno::Error;
// Reading from a file without permissions returns an error.
let mut path = temp_dir();
path.push("test");
let mut file = File::create(path).unwrap();
let mut buf: Vec<u8> = Vec::new();
assert!(file.read_to_end(&mut buf).is_err());
// Retrieve the error number of the previous operation using `Error::last()`:
let read_err = Error::last();
#[cfg(unix)]
assert_eq!(read_err, Error::new(libc::EBADF));
#[cfg(not(unix))]
assert_eq!(read_err, Error::new(libc::EIO));Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Error
impl UnwindSafe for Error
Blanket Implementations
Mutably borrows from an owned value. Read more