Struct Trace

Source
pub struct Trace {
    pub events: Vec<TraceEvent>,
    pub level: usize,
    pub active: bool,
    pub print: bool,
    pub panic_on_level: Option<usize>,
}
Expand description

Represents a single trace in the parsing process.

A Trace keeps track of parsing events, maintains the current nesting level, and can be configured for various tracing behaviors.

Fields§

§events: Vec<TraceEvent>

The collection of trace events.

§level: usize

The current nesting level of the trace.

§active: bool

Whether the trace is currently active and recording events.

§print: bool

Whether to print trace events in real-time.

§panic_on_level: Option<usize>

The maximum nesting level before panicking, if set.

Implementations§

Source§

impl Trace

Source

pub fn clear(&mut self)

Clears all recorded events and resets the nesting level to 0.

Source

pub fn open<I: AsRef<str>>( &mut self, context: Option<&'static str>, input: I, location: &'static str, silent: bool, ) -> usize

Records the opening of a parser in the trace.

§Arguments
  • context - Optional context information for the event.
  • input - The input being parsed.
  • location - The location (usually function name) where this event occurred.
  • silent - Whether to suppress real-time printing of this event.
§Returns

The new nesting level after recording this event.

Source

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

Records the closing of a parser in the trace.

§Arguments
  • context - Optional context information for the event.
  • input - The input being parsed.
  • location - The location (usually function name) where this event occurred.
  • result - The result of the parsing operation.
  • silent - Whether to suppress real-time printing of this event.
§Returns

The new nesting level after recording this event.

Source

pub fn set_level(&mut self, level: usize)

Sets the current nesting level of the trace.

§Arguments
  • level - The new nesting level to set.

Trait Implementations§

Source§

impl Default for Trace

Source§

fn default() -> Self

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

impl Display for Trace

Source§

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

Formats the entire trace for display.

This will format and display all events in the trace sequentially.

Auto Trait Implementations§

§

impl Freeze for Trace

§

impl RefUnwindSafe for Trace

§

impl Send for Trace

§

impl Sync for Trace

§

impl Unpin for Trace

§

impl UnwindSafe for Trace

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.