pub enum CompositionBinding<E: ProducerEffect> {
Standalone,
Wired(Arc<dyn CompositionDispatcher<Effect = E>>),
OwnerProvided {
dispatcher: Arc<dyn CompositionDispatcher<Effect = E>>,
context: Arc<dyn ContextProvider<E>>,
},
}Expand description
Typed binding attached to a runtime that holds a dispatcher.
Discriminates the “machine participates in a composition” case from the
“machine is standalone” case at the type level: no
Option<Arc<dyn CompositionDispatcher>>. Callers obtain the concrete
dispatcher via CompositionBinding::wired and honor
CompositionBinding::is_standalone to tell the two apart. The two
constructor halves on MeerkatMachine (with_composition(...) vs
standalone(...) / ephemeral() / persistent()) are the public
face of this distinction.
OwnerProvided (#342): some routes need consumer-side fields that
aren’t in the producer effect body — the canonical case is
session_id on the meerkat_mob_seam composition. The
OwnerProvided variant pairs a dispatcher with a typed
ContextProvider so the runtime that owns the dispatcher supplies
the missing fields from its own typed state at dispatch time.
OwnerProvided is semantically a superset of Wired: callers that
only need the dispatcher reach it through the same
wired accessor; callers that need the context
provider reach it through
context_provider, which returns Some
only for OwnerProvided.
Variants§
Standalone
Machine is not part of a composition. Routed-effect dispatch is not available.
Wired(Arc<dyn CompositionDispatcher<Effect = E>>)
Machine participates in a composition and owns a typed dispatcher. No owner-supplied context: all route bindings project from the producer’s effect body.
OwnerProvided
Machine participates in a composition that declares routes with
owner-supplied context (issue #342). The context is consulted
alongside the producer effect at dispatch time to fulfil route
bindings whose source is ContextField rather than
ProducerField.
Implementations§
Source§impl<E: ProducerEffect> CompositionBinding<E>
impl<E: ProducerEffect> CompositionBinding<E>
Sourcepub fn standalone() -> Self
pub fn standalone() -> Self
Construct a Standalone binding.
Mirrors MeerkatMachine::standalone(...) at the binding level so
call sites that wire a runtime without composition can say so
positively instead of spelling the enum variant. Equivalent to
CompositionBinding::Standalone.
Sourcepub fn wired_with(
dispatcher: Arc<dyn CompositionDispatcher<Effect = E>>,
) -> Self
pub fn wired_with( dispatcher: Arc<dyn CompositionDispatcher<Effect = E>>, ) -> Self
Construct a Wired binding from a composition dispatcher.
Use this when every route binding projects from the producer
effect body alone. If any route declares an owner-supplied
context field, use Self::owner_provided instead.
Sourcepub fn owner_provided(
dispatcher: Arc<dyn CompositionDispatcher<Effect = E>>,
context: Arc<dyn ContextProvider<E>>,
) -> Self
pub fn owner_provided( dispatcher: Arc<dyn CompositionDispatcher<Effect = E>>, context: Arc<dyn ContextProvider<E>>, ) -> Self
Construct an OwnerProvided binding from a composition
dispatcher and a typed context provider.
Use this for compositions whose route bindings reference owner- supplied context fields (per issue #342) — the provider is consulted at dispatch time for each routed effect so the missing fields can be fulfilled from the runtime’s own state.
Sourcepub fn is_standalone(&self) -> bool
pub fn is_standalone(&self) -> bool
Report whether this machine is standalone (no composition attached).
Sourcepub fn wired(&self) -> Option<&Arc<dyn CompositionDispatcher<Effect = E>>>
pub fn wired(&self) -> Option<&Arc<dyn CompositionDispatcher<Effect = E>>>
Borrow the wired dispatcher, if any.
Returns None only for CompositionBinding::Standalone.
Both Wired and OwnerProvided expose their dispatcher through
this accessor so call sites that only need to dispatch a typed
effect don’t have to branch on context-provider presence — the
type split exists so this is enforced at the construction
boundary, not re-checked at every call site.
Sourcepub fn context_provider(&self) -> Option<&Arc<dyn ContextProvider<E>>>
pub fn context_provider(&self) -> Option<&Arc<dyn ContextProvider<E>>>
Borrow the owner-supplied ContextProvider, if any.
Returns Some only for CompositionBinding::OwnerProvided.
Standalone has no dispatcher; Wired has a dispatcher but no
owner-supplied context, so callers that walk route bindings and
encounter a ContextField source on a Wired binding should
surface a typed refusal rather than silently treat it as an
empty context.