pub struct UseContext;Trait Implementations§
Source§impl<Context, SourceError> ErrorRaiser<Context, SourceError> for UseContextwhere
Context: HasErrorType + CanRaiseError<SourceError>,
Used for injecting external error types into Self::Error.
impl<Context, SourceError> ErrorRaiser<Context, SourceError> for UseContextwhere
Context: HasErrorType + CanRaiseError<SourceError>,
Used for injecting external error types into Self::Error.
As an example, if Context: CanRaiseError<ParseIntError>, then we would be
able to call Context::raise_error(err) for an error value
err: ParseIntError and get back
a Context::Error value.
fn raise_error(error: SourceError) -> <Context as HasErrorType>::Error
Source§impl<Context> ErrorTypeProvider<Context> for UseContextwhere
Context: HasErrorType,
This is used for contexts to declare that they have a unique Self::Error type.
impl<Context> ErrorTypeProvider<Context> for UseContextwhere
Context: HasErrorType,
This is used for contexts to declare that they have a unique Self::Error type.
Although it is possible for each context to declare their own associated
Error type, doing so may result in having multiple ambiguous Self::Error types,
if there are multiple associated types with the same name in different traits.
As a result, it is better for context traits to include HasError as their
parent traits, so that multiple traits can all refer to the same abstract
Self::Error type.
The Error associated type is also required to implement Debug.
This is to allow Self::Error to be used in calls like .unwrap(),
as well as for simpler error logging.
More details about how to use HasErrorType is available at
https://patterns.contextgeneric.dev/error-handling.html