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 + Copy + '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 Capability derive macro (in the crux_macros crate).

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 + Copy + '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 + Copy + 'static, Ev: 'static, NewEv: 'static + Send,

Implementors§

source§

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

§

type Operation = RenderOperation

§

type MappedSelf<MappedEv> = Render<MappedEv>