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§
Sourcefn bug(self) -> Result<T, Error>
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.
Sourcefn bug_context<C: Display + Send + Sync + 'static>(
self,
context: C,
) -> Result<T, Error>
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.
Sourcefn with_bug_context<C: Display + Send + Sync + 'static>(
self,
f: impl FnOnce() -> C,
) -> Result<T, Error>
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
.
Sourcefn user_message<C: Display + Send + Sync + 'static>(
self,
context: C,
) -> Result<T, Error>
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.
Sourcefn with_user_message<C: Display + Send + Sync + 'static>(
self,
f: impl FnOnce() -> C,
) -> Result<T, Error>
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.