Trait ErrorTypeProvider

Source
pub trait ErrorTypeProvider<Context>: IsProviderFor<ErrorTypeProviderComponent, Context, ()> {
    type Error: Debug;
}
Expand description

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

Required Associated Types§

Implementations on Foreign Types§

Source§

impl<Context> ErrorTypeProvider<Context> for UseContext
where 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

Source§

type Error = <Context as HasErrorType>::Error

Source§

impl<Error, Context> ErrorTypeProvider<Context> for UseType<Error>
where Error: Debug,

Source§

type Error = Error

Source§

impl<__Provider__, Context> ErrorTypeProvider<Context> for WithProvider<__Provider__>
where __Provider__: ProvideType<Context, ErrorTypeProviderComponent>, __Provider__::Type: Debug,

Source§

type Error = <__Provider__ as ProvideType<Context, ErrorTypeProviderComponent>>::Type

Implementors§

Source§

impl<Component, Context> ErrorTypeProvider<Context> for Component

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