Struct TraceTags

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

Manages multiple traces, each associated with a unique tag.

This struct allows for organizing and managing multiple trace instances, each identified by a static string tag. It provides methods for manipulating traces, such as activating, deactivating, and resetting them.

Fields§

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

Implementations§

Source§

impl TraceTags

Source

pub fn new() -> Self

Creates a new TraceTags instance with a default trace.

The default trace is associated with the DEFAULT_TAG.

Source

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

Resets the trace associated with the given tag.

If the tag doesn’t exist, a new trace is created and then reset.

Source

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

Retrieves the trace associated with the given tag as a string.

Returns None if the tag doesn’t exist.

Source

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

Activates the trace associated with the given tag.

If the tag doesn’t exist, a new trace is created and activated.

Source

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

Deactivates the trace associated with the given tag.

If the tag doesn’t exist, a new trace is created (but remains inactive).

Source

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

Activates real-time printing for the trace associated with the given tag.

This method is only available when the trace-print feature is enabled.

Source

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

Deactivates real-time printing for the trace associated with the given tag.

This method is only available when the trace-print feature is enabled.

Source

pub fn panic_on_level(&mut self, tag: &'static str, level: Option<usize>)

Sets the maximum nesting level for the trace associated with the given tag.

When the nesting level exceeds this value, the parser will panic. This method is only available when the trace-max-level feature is enabled.

Source

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

Records the opening of a parser in the trace associated with the given tag.

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>, silent: bool, )
where I: AsRef<str>,

Records the closing of a parser in the trace associated with the given tag.

Source

pub fn level_for_tag(&self, tag: &'static str) -> usize

Returns the current nesting level for the trace associated with the given tag.

If the tag doesn’t exist, returns 0.

Trait Implementations§

Source§

impl Default for TraceTags

Source§

fn default() -> TraceTags

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.