pub struct SchemaClassifier { /* private fields */ }Expand description
Recognizes the schema of parsed events from a set of signatures.
Signatures are sorted once at construction (specificity descending, then
name ascending) so classify returns the best match with
a single in-order scan.
Implementations§
Source§impl SchemaClassifier
impl SchemaClassifier
Sourcepub fn new(signatures: Vec<SchemaSignature>) -> Self
pub fn new(signatures: Vec<SchemaSignature>) -> Self
Build a classifier from an explicit signature set.
Sourcepub fn with_user_signatures(user: Vec<SchemaSignature>) -> Self
pub fn with_user_signatures(user: Vec<SchemaSignature>) -> Self
Build a classifier from the built-ins plus user-supplied signatures. User signatures are added to (not replacing) the built-ins; a user signature with a higher specificity than a built-in wins on overlap.
Sourcepub fn classify<E: Event + ?Sized>(&self, event: &E) -> Option<SchemaMatch>
pub fn classify<E: Event + ?Sized>(&self, event: &E) -> Option<SchemaMatch>
Classify an event. Returns the highest-specificity matching schema, or
None when the event matches no signature (“unknown”).
Sourcepub fn classify_with_ambiguity<E: Event + ?Sized>(
&self,
event: &E,
) -> (Option<SchemaMatch>, bool)
pub fn classify_with_ambiguity<E: Event + ?Sized>( &self, event: &E, ) -> (Option<SchemaMatch>, bool)
Classify and also report ambiguity: true when another signature with a
different name matches at the same (winning) specificity, so the winner
was chosen by the name tie-break rather than by specificity. Ambiguity
signals that routing intent may be nondeterministic and a signature
wants a distinguishing predicate or a specificity bump.
Sourcepub fn classify_all<E: Event + ?Sized>(&self, event: &E) -> Vec<String>
pub fn classify_all<E: Event + ?Sized>(&self, event: &E) -> Vec<String>
All matching schema names for an event, most specific first. Useful for tuning signatures (seeing what else an event could match). Deduplicated by name while preserving order.
Sourcepub fn explain<E: Event + ?Sized>(&self, event: &E) -> SchemaExplanation
pub fn explain<E: Event + ?Sized>(&self, event: &E) -> SchemaExplanation
Explain how an event classifies: the winning schema (if any) plus the signature that explains it (the winning signature, or for an unknown event the closest near-miss, the non-matching signature with the most passing predicates). For tuning signatures.
Sourcepub fn schema_names(&self) -> Vec<&str>
pub fn schema_names(&self) -> Vec<&str>
Distinct schema names this classifier can produce, most specific first.
Trait Implementations§
Source§impl Clone for SchemaClassifier
impl Clone for SchemaClassifier
Source§fn clone(&self) -> SchemaClassifier
fn clone(&self) -> SchemaClassifier
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more