Skip to main content

Router

Struct Router 

Source
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

Source

pub fn new() -> Self

Creates a new router with zeroed statistics.

Source

pub fn stats(&self) -> &RouterStats

Returns a reference to the router’s statistics.

Source

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.

Trait Implementations§

Source§

impl Default for Router

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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.