pub struct Router { /* private fields */ }Expand description
Dispatch router that matches raw log entries to category-specific parsers.
Holds a RouterStats that tracks routing outcomes for health monitoring.
The router is designed to be long-lived — create one at startup and reuse
it for every entry.
§Example
use manasight_parser::router::Router;
use manasight_parser::log::entry::{LogEntry, EntryHeader};
let router = Router::new();
let entry = LogEntry {
header: EntryHeader::UnityCrossThreadLogger,
body: "[UnityCrossThreadLogger]some unrecognized line".to_owned(),
};
let events = router.route(&entry);
assert!(events.is_empty());
assert_eq!(router.stats().unknown_count(), 1);Implementations§
Source§impl Router
impl Router
Sourcepub fn stats(&self) -> &RouterStats
pub fn stats(&self) -> &RouterStats
Returns a reference to the router’s statistics.
Sourcepub fn route(&self, entry: &LogEntry) -> Vec<GameEvent>
pub fn route(&self, entry: &LogEntry) -> Vec<GameEvent>
Routes a LogEntry to the appropriate parser.
Extracts the timestamp from the entry header line, then offers the
entry to each category parser in priority order. Returns a
Vec<GameEvent> with one or more events if a parser claims the
entry, or an empty Vec if unrecognized.
GRE entries may contain multiple batched GameStateMessage values
in a single log entry, producing multiple events from one entry.
When the timestamp cannot be parsed, None is passed to parsers
so downstream consumers can distinguish real timestamps from
missing ones. The timestamp failure is counted in RouterStats
and logged at debug level.