Skip to main content

CompositionBinding

Enum CompositionBinding 

Source
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.

Fields

§dispatcher: Arc<dyn CompositionDispatcher<Effect = E>>
§context: Arc<dyn ContextProvider<E>>

Implementations§

Source§

impl<E: ProducerEffect> CompositionBinding<E>

Source

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.

Source

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.

Source

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.

Source

pub fn is_standalone(&self) -> bool

Report whether this machine is standalone (no composition attached).

Source

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.

Source

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.

Trait Implementations§

Source§

impl<E: ProducerEffect> Debug for CompositionBinding<E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,