Struct vmap::Error[][src]

pub struct Error { /* fields omitted */ }
Expand description

A list specifying general categories of map errors.

Implementations

Returns an error that wraps a std::io::Error along with an Operation.

Examples
use std::io::ErrorKind;
use vmap::{Error, Operation};

println!("I/O error: {:?}", Error::io(
    Operation::MapFile,
    ErrorKind::NotFound.into(),
));

Returns an error that wraps an Input type along with an Operation.

Examples
use vmap::{Error, Operation, Input};

println!("Input error: {:?}", Error::input(
    Operation::MapFile,
    Input::InvalidRange,
));

Returns an error that wraps a system_error::Error along with an Operation.

Examples
use std::io::ErrorKind;
use vmap::{Error, Operation};

println!("System error: {:?}", Error::system(
    Operation::MapFile,
    system_error::Error::last_os_error()
));

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

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

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

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

Returns the corresponding Operation that cuased the error.

Examples
use vmap::{Error, Operation};

fn print_operation(err: Error) {
    println!("{:?}", err.operation());
}

// Will print "MapFile".
print_operation(Error::last_os_error(Operation::MapFile));

Trait Implementations

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The lower-level source of this error, if any. Read more

🔬 This is a nightly-only experimental API. (backtrace)

Returns a stack backtrace, if available, of where this error occurred. Read more

👎 Deprecated since 1.42.0:

use the Display impl or to_string()

👎 Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Converts the (Error, F) tuple from a ConvertResult result into an Error, dropping the failed map in the process.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.