pub struct DecodeLimits {
pub max_input_bytes: usize,
pub max_list_items: usize,
pub max_nesting_depth: usize,
pub max_total_allocation: usize,
}Expand description
Resource limits required by every untrusted decoder.
Fields§
§max_input_bytes: usizeMaximum accepted input length in bytes.
max_list_items: usizeMaximum items accepted in any decoded list.
max_nesting_depth: usizeMaximum nested list depth.
max_total_allocation: usizeMaximum total allocation a decoder may request.
Implementations§
Source§impl DecodeLimits
impl DecodeLimits
Sourcepub fn check_input_len(self, len: usize) -> Result<(), DecodeError>
pub fn check_input_len(self, len: usize) -> Result<(), DecodeError>
Validates the input length before parsing starts.
Sourcepub fn check_list_count(self, count: usize) -> Result<(), DecodeError>
pub fn check_list_count(self, count: usize) -> Result<(), DecodeError>
Validates a decoded list item count.
Sourcepub fn check_nesting_depth(self, depth: usize) -> Result<(), DecodeError>
pub fn check_nesting_depth(self, depth: usize) -> Result<(), DecodeError>
Validates the current nesting depth.
Sourcepub fn check_allocation(self, size: usize) -> Result<(), DecodeError>
pub fn check_allocation(self, size: usize) -> Result<(), DecodeError>
Validates one requested allocation against the allocation budget.
This helper is for single-allocation checks only. Decoders that can make
more than one allocation must use DecodeAccumulator to enforce the
cumulative budget.
Sourcepub const fn accumulator(self) -> DecodeAccumulator
pub const fn accumulator(self) -> DecodeAccumulator
Starts stateful budget accounting for a decoder invocation.
Trait Implementations§
Source§impl Clone for DecodeLimits
impl Clone for DecodeLimits
Source§fn clone(&self) -> DecodeLimits
fn clone(&self) -> DecodeLimits
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for DecodeLimits
Source§impl Debug for DecodeLimits
impl Debug for DecodeLimits
impl Eq for DecodeLimits
Source§impl PartialEq for DecodeLimits
impl PartialEq for DecodeLimits
Source§fn eq(&self, other: &DecodeLimits) -> bool
fn eq(&self, other: &DecodeLimits) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for DecodeLimits
Auto Trait Implementations§
impl Freeze for DecodeLimits
impl RefUnwindSafe for DecodeLimits
impl Send for DecodeLimits
impl Sync for DecodeLimits
impl Unpin for DecodeLimits
impl UnsafeUnpin for DecodeLimits
impl UnwindSafe for DecodeLimits
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