pub trait FfxContext<T, E> {
    // Required methods
    fn bug(self) -> Result<T, Error>;
    fn bug_context<C: Display + Send + Sync + 'static>(
        self,
        context: C
    ) -> Result<T, Error>;
    fn with_bug_context<C: Display + Send + Sync + 'static>(
        self,
        f: impl FnOnce() -> C
    ) -> Result<T, Error>;
    fn user_message<C: Display + Send + Sync + 'static>(
        self,
        context: C
    ) -> Result<T, Error>;
    fn with_user_message<C: Display + Send + Sync + 'static>(
        self,
        f: impl FnOnce() -> C
    ) -> Result<T, Error>;
}
Expand description

Adds helpers to result types to produce useful error messages to the user from the ffx frontend (through crate::Error)

Required Methods§

source

fn bug(self) -> Result<T, Error>

Make this error into a BUG check that will display to the user as an error that shouldn’t happen.

source

fn bug_context<C: Display + Send + Sync + 'static>( self, context: C ) -> Result<T, Error>

Make this error into a BUG check that will display to the user as an error that shouldn’t happen, with the added context.

source

fn with_bug_context<C: Display + Send + Sync + 'static>( self, f: impl FnOnce() -> C ) -> Result<T, Error>

Make this error into a BUG check that will display to the user as an error that shouldn’t happen, with the added context returned by the closure f.

source

fn user_message<C: Display + Send + Sync + 'static>( self, context: C ) -> Result<T, Error>

Make this error into a displayed user error, with the added context for display to the user. Use this for errors that happen in the normal course of execution, like files not being found.

source

fn with_user_message<C: Display + Send + Sync + 'static>( self, f: impl FnOnce() -> C ) -> Result<T, Error>

Make this error into a displayed user error, with the added context for display to the user. Use this for errors that happen in the normal course of execution, like files not being found.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T, E> FfxContext<T, E> for Result<T, E>
where Self: Context<T, E>, E: Into<Error>,

source§

fn bug(self) -> Result<T, Error>

source§

fn bug_context<C: Display + Send + Sync + 'static>( self, context: C ) -> Result<T, Error>

source§

fn with_bug_context<C: Display + Send + Sync + 'static>( self, f: impl FnOnce() -> C ) -> Result<T, Error>

source§

fn user_message<C: Display + Send + Sync + 'static>( self, context: C ) -> Result<T, Error>

source§

fn with_user_message<C: Display + Send + Sync + 'static>( self, f: impl FnOnce() -> C ) -> Result<T, Error>

Implementors§