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§
type Operation: Operation + DeserializeOwned
type MappedSelf<MappedEv>
Required Methods§
fn map_event<F, NewEv>(&self, f: F) -> Self::MappedSelf<NewEv>
Object Safety§
This trait is not object safe.