pub trait Capability<Ev> {
    type Operation: Operation;
    type MappedSelf<MappedEv>;

    // Required method
    fn map_event<F, NewEv>(&self, f: F) -> Self::MappedSelf<NewEv>
       where F: Fn(NewEv) -> Ev + Send + Sync + 'static,
             Ev: 'static,
             NewEv: 'static + Send;
}
Expand description

Implement the Capability trait for your capability. This will allow mapping events when composing apps from submodules.

Note that this implementation can be generated by the crux_core::macros::Capability derive macro.

Example:

impl<Ev> Capability<Ev> for Http<Ev> {
    type Operation = HttpOperation;
    type MappedSelf<MappedEv> = Http<MappedEv>;

    fn map_event<F, NewEvent>(&self, f: F) -> Self::MappedSelf<NewEvent>
    where
        F: Fn(NewEvent) -> Ev + Send + Sync + 'static,
        Ev: 'static,
        NewEvent: 'static,
    {
        Http::new(self.context.map_event(f))
    }
}

Required Associated Types§

Required Methods§

source

fn map_event<F, NewEv>(&self, f: F) -> Self::MappedSelf<NewEv>
where F: Fn(NewEv) -> Ev + Send + Sync + 'static, Ev: 'static, NewEv: 'static + Send,

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Ev> Capability<Ev> for Compose<Ev>

§

type Operation = Never

§

type MappedSelf<MappedEv> = Compose<MappedEv>

source§

impl<Ev> Capability<Ev> for Render<Ev>

§

type Operation = RenderOperation

§

type MappedSelf<MappedEv> = Render<MappedEv>