Skip to main content

MapEffectLayer

Struct MapEffectLayer 

Source
pub struct MapEffectLayer<Next, Effect>
where Next: Layer, Effect: 'static,
{ /* private fields */ }
Expand description

Middleware for converting the effect type to another type.

Typically, this is used to eliminate some of the effect variants which are processed by the layers below, so that code using this stack is not forced to have extraneous match arms which are never called.

Implementations§

Source§

impl<Next, Effect> MapEffectLayer<Next, Effect>
where Next: Layer,

Source

pub fn new(next: Next) -> Self

Trait Implementations§

Source§

impl<Next, Effect> Layer for MapEffectLayer<Next, Effect>
where Next: Layer, Effect: From<Next::Effect> + Send + 'static,

Source§

type Event = <Next as Layer>::Event

Event type expected by this layer
Source§

type Effect = Effect

Effect type returned by this layer
Source§

type ViewModel = <Next as Layer>::ViewModel

ViewModel returned by this layer
Source§

fn update<F>(&self, event: Self::Event, effect_callback: F) -> Vec<Self::Effect>
where F: Fn(Vec<Self::Effect>) + Sync + Send + 'static,

Process event from the Shell. Compared to Core::process_event this expects an additional argument - a callback to be called with effects requested outside of the initial call context. Read more
Source§

fn resolve<Output, F>( &self, request: &mut impl Resolvable<Output>, output: Output, effect_callback: F, ) -> Result<Vec<Self::Effect>, ResolveError>
where F: Fn(Vec<Self::Effect>) + Sync + Send + 'static,

Resolve a requested effect. Compared to Core::process_event this expects an additional argument - a callback to be called with effects requested outside of the initial call context. Read more
Source§

fn view(&self) -> Self::ViewModel

Return the current state of the view model
Source§

fn process_tasks<F>(&self, effect_callback: F) -> Vec<Self::Effect>
where F: Fn(Vec<Self::Effect>) + Sync + Send + 'static,

Process any tasks in the effect runtime of the Core, which are able to proceed. The tasks may produce effects which will be returned by the core and may be processed by lower middleware layers. Read more
Source§

fn handle_effects_using<EM>(self, middleware: EM) -> HandleEffectLayer<Self, EM>
where EM: EffectMiddleware + 'static, Self::Effect: TryInto<Request<EM::Op>, Error = Self::Effect>,

Wrap this layer with an effect handling middleware. The middleware argument must implement the EffectMiddleware trait.
Source§

fn map_effect<NewEffect>(self) -> MapEffectLayer<Self, NewEffect>
where NewEffect: From<Self::Effect> + Send + 'static,

Wrap this layer with an effect mapping middleware to change the Effect type returned. Read more
Source§

fn bridge<Format: FfiFormat>( self, effect_callback: impl Fn(Result<Vec<u8>, BridgeError<Format>>) + Send + Sync + 'static, ) -> Bridge<Self, Format>
where Self::Effect: EffectFFI, Self::Event: for<'a> Deserialize<'a>,

Auto Trait Implementations§

§

impl<Next, Effect> Freeze for MapEffectLayer<Next, Effect>
where Next: Freeze,

§

impl<Next, Effect> RefUnwindSafe for MapEffectLayer<Next, Effect>
where Next: RefUnwindSafe,

§

impl<Next, Effect> Send for MapEffectLayer<Next, Effect>

§

impl<Next, Effect> Sync for MapEffectLayer<Next, Effect>

§

impl<Next, Effect> Unpin for MapEffectLayer<Next, Effect>
where Next: Unpin,

§

impl<Next, Effect> UnsafeUnpin for MapEffectLayer<Next, Effect>
where Next: UnsafeUnpin,

§

impl<Next, Effect> UnwindSafe for MapEffectLayer<Next, Effect>
where Next: UnwindSafe,

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