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,
impl<C, O> ComposedDispatcher<C, O>where
O: Default,
Sourcepub fn with_strategy(self, strategy: MergeStrategy) -> Self
pub fn with_strategy(self, strategy: MergeStrategy) -> Self
Override the merge strategy.
Sourcepub fn strategy(&self) -> MergeStrategy
pub fn strategy(&self) -> MergeStrategy
The strategy this composition uses.
Sourcepub fn add<V>(
self,
label: &str,
source: SealedDispatcher<V, C, O>,
) -> Result<Self, DispatcherError>
pub fn add<V>( self, label: &str, source: SealedDispatcher<V, C, O>, ) -> Result<Self, DispatcherError>
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.
Sourcepub fn apply_each(&self, variants: &[Value], ctx: &mut C) -> Vec<O>where
O: Default,
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.
Sourcepub fn try_apply_each(
&self,
variants: &[Value],
ctx: &mut C,
) -> Result<Vec<O>, DispatcherError>where
O: Default,
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.
Sourcepub fn helper_count(&self) -> usize
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).
Sourcepub fn covered_kinds(&self) -> Vec<&str>
pub fn covered_kinds(&self) -> Vec<&str>
Read-only view of every kind covered by the composition, in canonical sorted order.
Sourcepub fn sources(&self) -> &[ComposedSource]
pub fn sources(&self) -> &[ComposedSource]
Read-only view of the sources contributing to the composition (label + kinds each contributed).