Struct UseContext

Source
pub struct UseContext;

Trait Implementations§

Source§

impl<Context, SourceError> ErrorRaiser<Context, SourceError> for UseContext
where 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.

Source§

fn raise_error(error: SourceError) -> <Context as HasErrorType>::Error

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<Context, Detail> ErrorWrapper<Context, Detail> for UseContext
where Context: HasErrorType + CanWrapError<Detail>,

Source§

fn wrap_error( error: <Context as HasErrorType>::Error, detail: Detail, ) -> <Context as HasErrorType>::Error

Source§

impl<Context, Tag, Field> FieldGetter<Context, Tag> for UseContext
where Context: HasField<Tag, Value = Field>,

Source§

type Value = Field

Source§

fn get_field( context: &Context, _tag: PhantomData<Tag>, ) -> &<UseContext as FieldGetter<Context, Tag>>::Value

Source§

impl<Context, Tag> ProvideType<Context, Tag> for UseContext
where Context: HasType<Tag>,

Source§

type Type = <Context as HasType<Tag>>::Type

Source§

impl<Context, SourceError> IsProviderFor<ErrorRaiserComponent, Context, SourceError> for UseContext
where Context: HasErrorType + CanRaiseError<SourceError>,

Source§

impl<Context> IsProviderFor<ErrorTypeProviderComponent, Context> for UseContext
where Context: HasErrorType,

Source§

impl<Context, Detail> IsProviderFor<ErrorWrapperComponent, Context, Detail> for UseContext
where Context: HasErrorType + CanWrapError<Detail>,

Source§

impl<Context, Tag> IsProviderFor<TypeComponent, Context, Tag> for UseContext
where Context: HasType<Tag>,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Getter, Context, Tag> FieldMapper<Context, Tag> for Getter
where Getter: FieldGetter<Context, Tag> + 'static, Tag: 'static,

Source§

fn map_field<T>( context: &Context, tag: PhantomData<Tag>, mapper: impl for<'a> FnOnce(&'a <Getter as FieldGetter<Context, Tag>>::Value) -> &'a T, ) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<A> Async for A
where A: Send + Sync,