Skip to main content

ChainedClassifier

Type Alias ChainedClassifier 

Source
pub type ChainedClassifier<I, O> = Chain<I, O>;
Expand description

Composes a chain of rules + a fallback into a single typed classifier. Each rule is tried in declared order; the first Some(out) wins. If no rule matches, the fallback fires.

As of the Chain extraction (PATTERN-EXTRACTION.md Pattern 3), ChainedClassifier<I, O> is a typed alias over the generic crate::chain::Chain<I, O>. Construction (Chain::new + with_rule) and the Classifier::classify impl are inherited from the generic via a blanket impl below.

Construction is fluent:

let c = ChainedClassifier::<str, FailureKind>::new(|_| FailureKind::Transient)
    .with_rule(|s| s.contains("does not exist").then_some(FailureKind::Declarative))
    .with_rule(|s| s.contains("infinite recursion").then_some(FailureKind::Declarative));

Aliased Type§

pub struct ChainedClassifier<I, O> { /* private fields */ }