Type Definition error_stack::Result

source ·
pub type Result<T, C> = Result<T, Report<C>>;
Expand description

Result<T, Report<C>>

A reasonable return type to use throughout an application.

The Result type can be used with one or two parameters, where the first parameter represents the Ok arm and the second parameter Context is used as in Report<C>.

Examples

Result can also be used in fn main():

use error_stack::{ensure, Result};

fn main() -> Result<(), AccessError> {
    let user = get_user()?;
    let resource = get_resource()?;

    ensure!(
        has_permission(user, resource),
        AccessError::PermissionDenied(user, resource)
    );

    ...
}

Trait Implementations§

source§

impl<T, C> ResultExt for Result<T, C>

§

type Ok = T

Type of the Ok value in the Result
source§

fn attach<A>(self, attachment: A) -> Selfwhere
    A: Send + Sync + 'static,

Adds a new attachment to the Report inside the Result. Read more
source§

fn attach_lazy<A, F>(self, attachment: F) -> Selfwhere
    A: Send + Sync + 'static,
    F: FnOnce() -> A,

Lazily adds a new attachment to the Report inside the Result. Read more
source§

fn attach_printable<A>(self, attachment: A) -> Selfwhere
    A: Display + Debug + Send + Sync + 'static,

Adds a new printable attachment to the Report inside the Result. Read more
source§

fn attach_printable_lazy<A, F>(self, attachment: F) -> Selfwhere
    A: Display + Debug + Send + Sync + 'static,
    F: FnOnce() -> A,

Lazily adds a new printable attachment to the Report inside the Result. Read more
source§

fn change_context<C2>(self, context: C2) -> Result<T, C2>where
    C2: Context,

Changes the context of the Report inside the Result. Read more
source§

fn change_context_lazy<C2, F>(self, context: F) -> Result<T, C2>where
    C2: Context,
    F: FnOnce() -> C2,

Lazily changes the context of the Report inside the Result. Read more