pub struct RecursionGuard { /* private fields */ }Expand description
Tracks recursion depth during parsing.
This is a lightweight wrapper that parsers use to track and enforce
recursion limits. It pairs with ParseConfig to provide the limit.
§Example
ⓘ
struct MyParser {
depth: RecursionGuard,
config: ParseConfig,
}
impl MyParser {
fn parse_nested(&mut self) -> Result<(), Error> {
self.depth.enter(self.config.max_recursion_depth)?;
// ... parse nested content ...
self.depth.exit();
Ok(())
}
}Implementations§
Source§impl RecursionGuard
impl RecursionGuard
Sourcepub fn enter(&mut self, limit: usize) -> Result<(), Error>
pub fn enter(&mut self, limit: usize) -> Result<(), Error>
Enter a nested context, incrementing depth.
Returns Err(Error::RecursionLimitExceeded) if the new depth would
exceed the limit.
§Arguments
limit- Maximum allowed depth (fromParseConfig::max_recursion_depth)
Trait Implementations§
Source§impl Clone for RecursionGuard
impl Clone for RecursionGuard
Source§fn clone(&self) -> RecursionGuard
fn clone(&self) -> RecursionGuard
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RecursionGuard
impl Debug for RecursionGuard
Source§impl Default for RecursionGuard
impl Default for RecursionGuard
Source§fn default() -> RecursionGuard
fn default() -> RecursionGuard
Returns the “default value” for a type. Read more
impl Copy for RecursionGuard
Auto Trait Implementations§
impl Freeze for RecursionGuard
impl RefUnwindSafe for RecursionGuard
impl Send for RecursionGuard
impl Sync for RecursionGuard
impl Unpin for RecursionGuard
impl UnwindSafe for RecursionGuard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more