Skip to main content

HandleEffectLayer

Struct HandleEffectLayer 

Source
pub struct HandleEffectLayer<Next, EM>
where Next: Layer + Sync + Send + 'static, Next::Effect: TryInto<Request<EM::Op>, Error = Next::Effect>, EM: EffectMiddleware,
{ /* private fields */ }
Expand description

Middleware layer able to process some of the effects. This implements the general behaviour making sure all follow-up effects are processed and routed to the right place and delegates to the generic parameter EM, which implements EffectMiddleware.

Implementations§

Source§

impl<Next, EM> HandleEffectLayer<Next, EM>
where Next: Layer, Next::Effect: TryInto<Request<EM::Op>, Error = Next::Effect>, EM: EffectMiddleware + 'static,

Source

pub fn new(next: Next, middleware: EM) -> Self

Typically, you would use Layer::handle_effects_using to construct a HandleEffectLayer instance for a specific EffectMiddleware.

Trait Implementations§

Source§

impl<Next, EM> Layer for HandleEffectLayer<Next, EM>
where Next: Layer, Next::Effect: TryInto<Request<EM::Op>, Error = Next::Effect>, EM: EffectMiddleware + 'static,

Source§

type Event = <Next as Layer>::Event

Event type expected by this layer
Source§

type Effect = <Next as Layer>::Effect

Effect type returned by this layer
Source§

type ViewModel = <Next as Layer>::ViewModel

ViewModel returned by this layer
Source§

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

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: Fn(Vec<Self::Effect>) + Send + Sync + 'static>( &self, request: &mut impl Resolvable<Output>, output: Output, effect_callback: F, ) -> Result<Vec<Self::Effect>, ResolveError>

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, EM> Freeze for HandleEffectLayer<Next, EM>
where <Next as Layer>::Effect: Sized,

§

impl<Next, EM> RefUnwindSafe for HandleEffectLayer<Next, EM>
where <Next as Layer>::Effect: Sized, Next: RefUnwindSafe, EM: RefUnwindSafe,

§

impl<Next, EM> Send for HandleEffectLayer<Next, EM>
where <Next as Layer>::Effect: Sized,

§

impl<Next, EM> Sync for HandleEffectLayer<Next, EM>
where <Next as Layer>::Effect: Sized,

§

impl<Next, EM> Unpin for HandleEffectLayer<Next, EM>
where <Next as Layer>::Effect: Sized,

§

impl<Next, EM> UnsafeUnpin for HandleEffectLayer<Next, EM>
where <Next as Layer>::Effect: Sized,

§

impl<Next, EM> UnwindSafe for HandleEffectLayer<Next, EM>
where <Next as Layer>::Effect: Sized, Next: RefUnwindSafe, EM: RefUnwindSafe,

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.