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
impl TraceTags
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new TraceTags
instance with a default trace.
The default trace is associated with the DEFAULT_TAG.
Sourcepub fn clear(&mut self, tag: &'static str)
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.
Sourcepub fn get_trace(&self, tag: &'static str) -> Option<String>
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.
Sourcepub fn activate(&mut self, tag: &'static str)
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.
Sourcepub fn deactivate(&mut self, tag: &'static str)
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).
Sourcepub fn activate_trace_print(&mut self, tag: &'static str)
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.
Sourcepub fn deactivate_trace_print(&mut self, tag: &'static str)
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.
Sourcepub fn panic_on_level(&mut self, tag: &'static str, level: Option<usize>)
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.
Sourcepub fn open<I>(
&mut self,
tag: &'static str,
context: Option<&'static str>,
input: I,
location: &'static str,
silent: bool,
)
pub fn open<I>( &mut self, tag: &'static str, context: Option<&'static str>, input: I, location: &'static str, silent: bool, )
Records the opening of a parser in the trace associated with the given tag.
Sourcepub 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,
)
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, )
Records the closing of a parser in the trace associated with the given tag.
Sourcepub fn level_for_tag(&self, tag: &'static str) -> usize
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.