pub struct ParseLimits { /* private fields */ }Expand description
Resource bounds checked while parsing a document.
All limits are inclusive: a source whose byte length equals the byte limit
is accepted, as is a parser stream with exactly the event limit. A zero
value rejects any input that consumes that resource. Nesting values above
ParseLimits::MAX_NESTING_DEPTH are capped during construction.
Implementations§
Source§impl ParseLimits
impl ParseLimits
Sourcepub const MAX_NESTING_DEPTH: usize = 128
pub const MAX_NESTING_DEPTH: usize = 128
The parser’s absolute nesting ceiling.
Sourcepub const fn new(
max_source_bytes: usize,
max_nesting_depth: usize,
max_events: usize,
) -> Self
pub const fn new( max_source_bytes: usize, max_nesting_depth: usize, max_events: usize, ) -> Self
Creates a complete resource budget.
Sourcepub const fn max_source_bytes(self) -> usize
pub const fn max_source_bytes(self) -> usize
Returns the maximum accepted UTF-8 source size in bytes.
Sourcepub const fn max_nesting_depth(self) -> usize
pub const fn max_nesting_depth(self) -> usize
Returns the effective maximum parser-container depth.
Sourcepub const fn max_events(self) -> usize
pub const fn max_events(self) -> usize
Returns the maximum accepted parser-event count.
Sourcepub const fn with_max_source_bytes(self, bytes: usize) -> Self
pub const fn with_max_source_bytes(self, bytes: usize) -> Self
Replaces the source byte limit.
Sourcepub const fn with_max_nesting_depth(self, depth: usize) -> Self
pub const fn with_max_nesting_depth(self, depth: usize) -> Self
Replaces the nesting limit, capped at
ParseLimits::MAX_NESTING_DEPTH.
Sourcepub const fn with_max_events(self, events: usize) -> Self
pub const fn with_max_events(self, events: usize) -> Self
Replaces the parser-event limit.
Trait Implementations§
Source§impl Clone for ParseLimits
impl Clone for ParseLimits
impl Copy for ParseLimits
Source§impl Debug for ParseLimits
impl Debug for ParseLimits
Source§impl Default for ParseLimits
impl Default for ParseLimits
impl Eq for ParseLimits
Source§impl PartialEq for ParseLimits
impl PartialEq for ParseLimits
impl StructuralPartialEq for ParseLimits
Auto Trait Implementations§
impl Forget for ParseLimits
impl Freeze for ParseLimits
impl RefUnwindSafe for ParseLimits
impl Send for ParseLimits
impl Sync for ParseLimits
impl Unpin for ParseLimits
impl UnsafeUnpin for ParseLimits
impl UnwindSafe for ParseLimits
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