pub struct ParseLimits { /* private fields */ }Expand description
Resource limits applied while parsing untrusted bencode.
Implementations§
Source§impl ParseLimits
impl ParseLimits
Sourcepub const fn new(
max_depth: usize,
max_items: usize,
max_byte_string_length: usize,
max_total_input: usize,
max_owned_allocation: usize,
) -> Self
pub const fn new( max_depth: usize, max_items: usize, max_byte_string_length: usize, max_total_input: usize, max_owned_allocation: usize, ) -> Self
Creates a complete parser limit configuration.
Sourcepub const fn max_byte_string_length(self) -> usize
pub const fn max_byte_string_length(self) -> usize
Returns the maximum byte-string length.
Sourcepub const fn max_integer_digits(self) -> usize
pub const fn max_integer_digits(self) -> usize
Returns the maximum number of integer digits, excluding a minus sign.
Sourcepub const fn with_max_integer_digits(self, maximum: usize) -> Self
pub const fn with_max_integer_digits(self, maximum: usize) -> Self
Replaces the maximum integer digit count.
Sourcepub const fn max_total_input(self) -> usize
pub const fn max_total_input(self) -> usize
Returns the maximum total input length.
Sourcepub const fn max_owned_allocation(self) -> usize
pub const fn max_owned_allocation(self) -> usize
Returns the maximum budget for allocations made by owned conversion.
Sourcepub const fn check_depth(self, actual: usize) -> Result<()>
pub const fn check_depth(self, actual: usize) -> Result<()>
Checks a nesting depth against the configured maximum.
§Errors
Returns a resource-limit error when actual exceeds the maximum depth.
Sourcepub const fn check_items(self, actual: usize) -> Result<()>
pub const fn check_items(self, actual: usize) -> Result<()>
Checks an item count against the configured maximum.
§Errors
Returns a resource-limit error when actual exceeds the maximum count.
Sourcepub const fn check_byte_string_length(self, actual: usize) -> Result<()>
pub const fn check_byte_string_length(self, actual: usize) -> Result<()>
Checks a byte-string length against the configured maximum.
§Errors
Returns a resource-limit error when actual exceeds the maximum length.
Sourcepub const fn check_integer_digits(self, actual: usize) -> Result<()>
pub const fn check_integer_digits(self, actual: usize) -> Result<()>
Checks an integer digit count against the configured maximum.
§Errors
Returns a resource-limit error when actual exceeds the maximum count.
Trait Implementations§
Source§impl Clone for ParseLimits
impl Clone for ParseLimits
Source§fn clone(&self) -> ParseLimits
fn clone(&self) -> ParseLimits
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more