Sha256: 622a4953d80eb99b894ad8065770f2e054efc3eca0c3b6fbe66288e55559465d

Contents?: true

Size: 1.04 KB

Versions: 38

Compression:

Stored size: 1.04 KB

Contents

//! Error handling.
use std::fmt;

/// Enumeration of errors possible in this library
#[derive(Debug)]
pub enum Error {
    /// Cannot create the memfd
    Create(std::io::Error),
    /// Cannot add new seals to the memfd
    AddSeals(std::io::Error),
    /// Cannot read the seals of a memfd
    GetSeals(std::io::Error),
}

impl std::error::Error for Error {
    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
        match self {
            Error::Create(e) | Error::AddSeals(e) | Error::GetSeals(e) => Some(e),
        }
    }
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str(match self {
            Error::Create(_) => "cannot create a memfd",
            Error::AddSeals(_) => "cannot add seals to the memfd",
            Error::GetSeals(_) => "cannot read seals for a memfd",
        })
    }
}

#[cfg(test)]
#[test]
fn error_send_sync() {
    fn assert_error<E: std::error::Error + Send + Sync + fmt::Display + fmt::Debug + 'static>() {}
    assert_error::<Error>();
}

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-28.0.0 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-27.0.0 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-26.0.0 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-25.0.2 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-25.0.1 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-25.0.0 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-24.0.0 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-23.0.2 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-22.0.0 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-21.0.1 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-20.0.2 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-20.0.0 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-18.0.3 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-17.0.1 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-17.0.0 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-16.0.0 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-15.0.1 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-15.0.0 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs
wasmtime-14.0.4 ./ext/cargo-vendor/memfd-0.6.4/src/errors.rs