Trait crux_core::capability::WithContext
source · pub trait WithContext<Ev, Ef> {
// Required method
fn new_with_context(context: ProtoContext<Ef, Ev>) -> Self;
}
Expand description
Allows Crux to construct app’s set of required capabilities, providing context they can then use to request effects and dispatch events.
new_with_context
is called by Crux and should return an instance of the app’s Capabilities
type with
all capabilities constructed with context passed in. Use Context::specialize
to
create an appropriate context instance with the effect constructor which should
wrap the requested operations.
Note that this implementation can be generated by the derive macro crux_core::macros::Effect
.
impl crux_core::WithContext<Event, Effect> for Capabilities {
fn new_with_context(
context: crux_core::capability::ProtoContext<Effect, Event>,
) -> Capabilities {
Capabilities {
http: crux_http::Http::new(context.specialize(Effect::Http)),
render: crux_core::render::Render::new(context.specialize(Effect::Render)),
}
}
}
Required Methods§
fn new_with_context(context: ProtoContext<Ef, Ev>) -> Self
Object Safety§
This trait is not object safe.