[][src]Struct kvm_ioctls::Error

pub struct Error(_);

Wrapper over errno.

The error number is an integer number set by system calls and some libc functions in case of error.

Implementations

impl Error[src]

pub fn new(errno: i32) -> Error[src]

Creates a new error from the given error number.

Arguments

  • errno: error number used for creating the Error.

Examples

extern crate vmm_sys_util;
use vmm_sys_util::errno::Error;

let err = Error::new(libc::EIO);

pub fn last() -> Error[src]

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));

pub fn errno(self) -> i32[src]

Returns the raw integer value (errno) corresponding to this Error.

Examples

extern crate vmm_sys_util;
use vmm_sys_util::errno::Error;

let err = Error::new(13);
assert_eq!(err.errno(), 13);

Trait Implementations

impl Clone for Error[src]

impl Copy for Error[src]

impl Debug for Error[src]

impl Display for Error[src]

impl Error for Error[src]

impl From<Error> for Error[src]

impl PartialEq<Error> for Error[src]

impl StructuralPartialEq for Error[src]

Auto Trait Implementations

impl RefUnwindSafe for Error

impl Send for Error

impl Sync for Error

impl Unpin for Error

impl UnwindSafe for Error

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.