Skip to main content

ParserHealth

Struct ParserHealth 

Source
pub struct ParserHealth {
    pub total_events: u64,
    pub parsed_events: u64,
    pub partial_events: u64,
    pub ignored_events: u64,
    pub control_events: u64,
    pub unknown_events: u64,
    pub parse_errors: u64,
}
Expand description

Parser health statistics

Fields§

§total_events: u64

Total number of events processed

§parsed_events: u64

Number of events successfully parsed and displayed

§partial_events: u64

Number of partial/delta events (streaming content displayed incrementally)

§ignored_events: u64

Number of events ignored (malformed JSON, unknown events, etc.)

§control_events: u64

Number of control events (state management, no user output)

§unknown_events: u64

Number of unknown event types (valid JSON but unhandled)

§parse_errors: u64

Number of JSON parse errors (malformed JSON)

Implementations§

Source§

impl ParserHealth

Source

pub fn new() -> Self

Create a new health tracker

Source

pub const fn record_parsed(&mut self)

Record a parsed event

Source

pub const fn record_ignored(&mut self)

Record an ignored event

Source

pub const fn record_unknown_event(&mut self)

Record an unknown event type (valid JSON but unhandled)

Unknown events are valid JSON that the parser deserialized successfully but doesn’t have specific handling for. These should not trigger health warnings as they represent future/new event types, not parser errors.

Source

pub const fn record_parse_error(&mut self)

Record a parse error (malformed JSON)

Source

pub const fn record_control_event(&mut self)

Record a control event (state management with no user-facing output)

Control events are valid JSON that represent state transitions rather than user-facing content. They should not be counted as “ignored” for health monitoring purposes.

Source

pub const fn record_partial_event(&mut self)

Record a partial/delta event (streaming content displayed incrementally)

Partial events represent streaming content that is shown to the user in real-time as deltas. These are NOT errors and should not trigger health warnings. They are tracked separately to show streaming activity.

Source

pub fn parse_error_percentage(&self) -> f64

Get the percentage of parse errors (excluding unknown events)

Returns percentage using integer-safe arithmetic to avoid precision loss warnings.

Source

pub fn parse_error_percentage_int(&self) -> u32

Get the percentage of parse errors as a rounded integer.

This is for display purposes where a whole number is sufficient.

Source

pub fn is_concerning(&self) -> bool

Check if the parser health is concerning

Only returns true if there are actual parse errors (malformed JSON), not just unknown event types. Unknown events are valid JSON that we don’t have specific handling for, which is not a health concern.

Source

pub fn warning(&self, parser_name: &str, colors: Colors) -> Option<String>

Get a warning message if health is concerning

Trait Implementations§

Source§

impl Clone for ParserHealth

Source§

fn clone(&self) -> ParserHealth

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParserHealth

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ParserHealth

Source§

fn default() -> ParserHealth

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

impl Copy for ParserHealth

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.