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

Type of the Ok value in the Result
Adds a new attachment to the Report inside the Result. Read more
Lazily adds a new attachment to the Report inside the Result. Read more
Adds a new printable attachment to the Report inside the Result. Read more
Lazily adds a new printable attachment to the Report inside the Result. Read more
Changes the context of the Report inside the Result. Read more
Lazily changes the context of the Report inside the Result. Read more