pub struct Limits {
pub max_input: Option<usize>,
pub max_depth: Option<u32>,
pub max_steps: Option<u64>,
}Expand description
The most a parse may cost. None is no limit.
use parsec_base::Limits;
let limits = Limits { max_input: Some(1 << 20), ..Limits::default() };
assert!(limits.check_input(2 << 20).is_err());Fields§
§max_input: Option<usize>The longest input in bytes. Parsers using Span never take more
than Span::MAX_INPUT, whatever this says.
max_depth: Option<u32>How deep the parser’s tree may nest.
max_steps: Option<u64>The work a parse may do, in the steps its parser counts.
Implementations§
Source§impl Limits
impl Limits
Sourcepub fn check_input(&self, len: usize) -> Result<(), Diagnostic>
pub fn check_input(&self, len: usize) -> Result<(), Diagnostic>
An input-too-large error if len bytes are over the limit, or
over Span::MAX_INPUT.
Sourcepub fn budget(&self) -> Budget
pub fn budget(&self) -> Budget
A budget of Limits::max_steps.
Trait Implementations§
impl Copy for Limits
impl Eq for Limits
impl StructuralPartialEq for Limits
Auto Trait Implementations§
impl Forget for Limits
impl Freeze for Limits
impl Move for Limits
impl RefUnwindSafe for Limits
impl Send for Limits
impl Sync for Limits
impl Unpin for Limits
impl UnsafeUnpin for Limits
impl UnwindSafe for Limits
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