Struct lair_keystore::dependencies::one_err::OneErr

source ·
pub struct OneErr(/* private fields */);
Expand description

OneErr to rule them all. See crate docs for usage.

Implementations§

source§

impl OneErr

source

pub fn new<K>(kind: K) -> OneErr
where K: Display,

Create a new OneErr error instance.

source

pub fn with_message<K, M>(kind: K, message: M) -> OneErr
where K: Display, M: Display,

Create a new OneErr error instance with a message.

source

pub fn io_kind(&self) -> ErrorKind

Get the std::io::ErrorKind associated with this instance.

source

pub fn errno(&self) -> ErrNo

Get the ErrNo associated with this instance, if any.

source

pub fn str_kind(&self) -> &str

Get the &str kind associated with this instance. This can be more descriptive where io_kind() or errno() might return ‘Other’.

source

pub fn as_io(&self) -> &Error

Get a reference to the inner std::io::Error of this instance.

source

pub fn set_field<K, T>(&mut self, name: &K, t: T) -> &mut OneErr
where K: Display + ?Sized, T: Into<Value>,

Set an additional data field on this OneErr. Will panic on reserved names: “error”, “os”, “source”, “backtrace”, “message”.

source

pub fn get_message(&self) -> Option<&str>

Get the message associated with this instance, or empty string.

source

pub fn get_field<'lt, R, V>(&'lt self, name: R) -> Option<V>
where R: AsRef<str>, Option<V>: From<&'lt Value>,

Get the value of an additional field associated with this error, or None if no such field exists. Valid output types: &str, bool, i64, u64, and f64.

Methods from Deref<Target = Error>§

1.0.0 · source

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 or from_raw_os_error, then this function will return Some, otherwise it will return None.

§Examples
use std::io::{Error, ErrorKind};

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

fn main() {
    // Will print "raw OS error: ...".
    print_os_error(&Error::last_os_error());
    // Will print "Not an OS error".
    print_os_error(&Error::new(ErrorKind::Other, "oh no!"));
}
1.3.0 · source

pub fn get_ref(&self) -> Option<&(dyn Error + Sync + Send + 'static)>

Returns a reference to the inner error wrapped by this error (if any).

If this Error was constructed via new then this function will return Some, otherwise it will return None.

§Examples
use std::io::{Error, ErrorKind};

fn print_error(err: &Error) {
    if let Some(inner_err) = err.get_ref() {
        println!("Inner error: {inner_err:?}");
    } else {
        println!("No inner error");
    }
}

fn main() {
    // Will print "No inner error".
    print_error(&Error::last_os_error());
    // Will print "Inner error: ...".
    print_error(&Error::new(ErrorKind::Other, "oh no!"));
}
1.0.0 · source

pub fn kind(&self) -> ErrorKind

Returns the corresponding ErrorKind for this error.

This may be a value set by Rust code constructing custom io::Errors, or if this io::Error was sourced from the operating system, it will be a value inferred from the system’s error encoding. See last_os_error for more details.

§Examples
use std::io::{Error, ErrorKind};

fn print_error(err: Error) {
    println!("{:?}", err.kind());
}

fn main() {
    // As no error has (visibly) occurred, this may print anything!
    // It likely prints a placeholder for unidentified (non-)errors.
    print_error(Error::last_os_error());
    // Will print "AddrInUse".
    print_error(Error::new(ErrorKind::AddrInUse, "oh no!"));
}

Trait Implementations§

source§

impl AsRef<Error> for OneErr

source§

fn as_ref(&self) -> &Error

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for OneErr

source§

fn clone(&self) -> OneErr

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for OneErr

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Deref for OneErr

§

type Target = Error

The resulting type after dereferencing.
source§

fn deref(&self) -> &<OneErr as Deref>::Target

Dereferences the value.
source§

impl<'de> Deserialize<'de> for OneErr

source§

fn deserialize<D>( deserializer: D, ) -> Result<OneErr, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for OneErr

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Error for OneErr

1.30.0 · source§

fn source(&self) -> Option<&(dyn Error + 'static)>

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

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
source§

impl From<&OneErr> for Error

source§

fn from(e: &OneErr) -> Error

Converts to this type from the input type.
source§

impl From<&OneErr> for SodokenErrKind

source§

fn from(e: &OneErr) -> SodokenErrKind

Converts to this type from the input type.
source§

impl From<&String> for OneErr

source§

fn from(s: &String) -> OneErr

Converts to this type from the input type.
source§

impl From<&str> for OneErr

source§

fn from(s: &str) -> OneErr

Converts to this type from the input type.
source§

impl From<()> for OneErr

source§

fn from(_: ()) -> OneErr

Converts to this type from the input type.
source§

impl From<ErrNo> for OneErr

source§

fn from(e: ErrNo) -> OneErr

Converts to this type from the input type.
source§

impl From<Error> for OneErr

source§

fn from(e: Error) -> OneErr

Converts to this type from the input type.
source§

impl From<ErrorKind> for OneErr

source§

fn from(k: ErrorKind) -> OneErr

Converts to this type from the input type.
source§

impl From<OneErr> for Error

source§

fn from(e: OneErr) -> Error

Converts to this type from the input type.
source§

impl From<SodokenErrKind> for OneErr

source§

fn from(k: SodokenErrKind) -> OneErr

Converts to this type from the input type.
source§

impl From<String> for OneErr

source§

fn from(s: String) -> OneErr

Converts to this type from the input type.
source§

impl From<i32> for OneErr

source§

fn from(e: i32) -> OneErr

Converts to this type from the input type.
source§

impl FromStr for OneErr

§

type Err = OneErr

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<OneErr, <OneErr as FromStr>::Err>

Parses a string s to return a value of this type. Read more
source§

impl PartialEq for OneErr

source§

fn eq(&self, oth: &OneErr) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for OneErr

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for OneErr

Auto Trait Implementations§

§

impl Freeze for OneErr

§

impl !RefUnwindSafe for OneErr

§

impl Send for OneErr

§

impl Sync for OneErr

§

impl Unpin for OneErr

§

impl !UnwindSafe for OneErr

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,