Skip to main content

NotFound

Trait NotFound 

Source
pub trait NotFound<T> {
    // Required methods
    fn is_not_found(&self) -> bool;
    fn optional(self) -> Result<Option<T>>;
    fn is_missing(&self) -> bool;
    fn present(self) -> Result<Option<T>>;
}
Expand description

Classifies and adapts results carrying the crate’s not-found error family.

Successful results and unrelated errors are not classified as not found, and only a not-found error converts to an absent value. Classification delegates to Error::is_not_found, or to the narrower Error::is_missing for the forms that must not read a storage fault as absence.

Required Methods§

Source

fn is_not_found(&self) -> bool

Reports whether the result contains a not-found error.

An Ok value always returns false. Other error variants also return false without changing the result.

Source

fn optional(self) -> Result<Option<T>>

Converts a not-found error into an absent value.

An Ok value is wrapped in Some and a not-found error becomes Ok(None), so a caller distinguishes an absent value from a failed operation. Every other error is returned unchanged.

Source

fn is_missing(&self) -> bool

Reports whether the result contains a missing-record error.

Unlike is_not_found, an I/O not-found or any other error mapping to 404 returns false.

Source

fn present(self) -> Result<Option<T>>

Converts only a missing-record error into an absent value.

Like optional, but an I/O not-found and any other error mapping to 404 are returned unchanged, so a storage fault never reads as absence.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> NotFound<T> for Result<T, Error>