Trait crux_core::capability::Capability

source ·
pub trait Capability<Ev> {
    type Operation: Operation + DeserializeOwned;
    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 = HttpRequest;
    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>

source§

type Operation = Never

source§

type MappedSelf<MappedEv> = Compose<MappedEv>

source§

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