Skip to main content

ComposedDispatcher

Struct ComposedDispatcher 

Source
pub struct ComposedDispatcher<C, O> { /* private fields */ }
Expand description

Composition of multiple SealedDispatchers over disjoint variant universes. Operates on serde_json::Value variants keyed by the "kind" field. Use .add(...) to extend.

Implementations§

Source§

impl<C, O> ComposedDispatcher<C, O>
where O: Default,

Source

pub fn new() -> Self

Start a fresh composition with the default strategy.

Source

pub fn with_strategy(self, strategy: MergeStrategy) -> Self

Override the merge strategy.

Source

pub fn strategy(&self) -> MergeStrategy

The strategy this composition uses.

Source

pub fn add<V>( self, label: &str, source: SealedDispatcher<V, C, O>, ) -> Result<Self, DispatcherError>
where V: TypedDispatcher + Serialize + DeserializeOwned + 'static, C: 'static, O: 'static,

Extend with another sealed dispatcher. Kinds must be disjoint from any already-added source — overlap raises DuplicateHelper (which here means “the composition’s kind universes overlap; pick one source for each kind”).

label is a fleet-unique tag for the source (typically matches the register_dispatcher! label).

§Errors

Returns DispatcherError::DuplicateHelper if any of the added dispatcher’s kinds is already covered.

Source

pub fn apply_each(&self, variants: &[Value], ctx: &mut C) -> Vec<O>
where O: Default,

Apply each serde_json::Value variant against the composed helpers. Unknown kinds skip silently — use try_apply_each for typed UnknownKind reporting.

Source

pub fn try_apply_each( &self, variants: &[Value], ctx: &mut C, ) -> Result<Vec<O>, DispatcherError>
where O: Default,

apply_each with explicit error surfacing.

§Errors

Returns DispatcherError::UnknownKind if a variant’s kind has no registered helper across the composition.

Source

pub fn helper_count(&self) -> usize

Number of helpers in the composition (sum of source helpers; equal to the disjoint union of source variant universes).

Source

pub fn covered_kinds(&self) -> Vec<&str>

Read-only view of every kind covered by the composition, in canonical sorted order.

Source

pub fn sources(&self) -> &[ComposedSource]

Read-only view of the sources contributing to the composition (label + kinds each contributed).

Trait Implementations§

Source§

impl<C, O> Default for ComposedDispatcher<C, O>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<C, O> !RefUnwindSafe for ComposedDispatcher<C, O>

§

impl<C, O> !UnwindSafe for ComposedDispatcher<C, O>

§

impl<C, O> Freeze for ComposedDispatcher<C, O>

§

impl<C, O> Send for ComposedDispatcher<C, O>

§

impl<C, O> Sync for ComposedDispatcher<C, O>

§

impl<C, O> Unpin for ComposedDispatcher<C, O>

§

impl<C, O> UnsafeUnpin for ComposedDispatcher<C, O>

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