ffx_command_error

Trait FfxContext

Source
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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> FfxContext<T, Infallible> for Option<T>
where Self: Context<T, Infallible>,

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>

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§