nom_tracer

Struct TraceList

source
pub struct TraceList {
    pub traces: HashMap<&'static str, Trace>,
}
Expand description

A collection of traces, each associated with a tag.

The tag system allows for multiple independent traces to be maintained simultaneously. Each tag corresponds to a separate Trace instance, allowing for organization and separation of trace events based on different criteria (e.g., parser type, subsystem, etc.).

Fields§

§traces: HashMap<&'static str, Trace>

Implementations§

source§

impl TraceList

source

pub fn new() -> Self

Creates a new TraceList with a default trace.

The default trace is associated with the DEFAULT_TAG.

source

pub fn reset(&mut self, tag: &'static str)

Resets the trace for the given tag.

This clears all events and resets the nesting level for the specified trace. If the trace doesn’t exist, a new one is created and inserted.

source

pub fn get_trace(&self, tag: &'static str) -> Option<String>

Returns the trace for the given tag as a string, if it exists.

source

pub fn activate(&mut self, tag: &'static str)

Activates the trace for the given tag.

Activated traces will record events. If the trace doesn’t exist, a new one is created and activated.

source

pub fn deactivate(&mut self, tag: &'static str)

Deactivates the trace for the given tag.

Deactivated traces will not record events, but will retain previously recorded events. If the trace doesn’t exist, a new one is created (but left inactive).

source

pub fn open<I>( &mut self, tag: &'static str, context: Option<&'static str>, input: I, location: &'static str, )
where I: AsRef<str>,

Opens a new trace event for the given tag.

This increases the nesting level for the trace and records an ‘open’ event. The hierarchical structure of parsing is represented by these nested open/close events.

source

pub fn close<I, O: Debug, E: Debug>( &mut self, tag: &'static str, context: Option<&'static str>, input: I, location: &'static str, result: &IResult<I, O, E>, )
where I: AsRef<str>,

Closes the current trace event for the given tag.

This decreases the nesting level for the trace and records a ‘close’ event, including the result of the parsing operation (success, error, etc.). The hierarchical structure is maintained by matching each ‘close’ with a previous ‘open’.

Trait Implementations§

source§

impl Default for TraceList

source§

fn default() -> TraceList

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, 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.