pub struct DecodeLimits {
pub max_input_bytes: usize,
pub max_depth: usize,
pub max_total_items: usize,
pub max_array_len: usize,
pub max_map_len: usize,
pub max_bytes_len: usize,
pub max_text_len: usize,
}Expand description
Decode-time resource limits for validation and decoding.
Limits are enforced deterministically and must not depend on background timers.
Fields§
§max_input_bytes: usizeMaximum total input length in bytes.
max_depth: usizeMaximum nesting depth.
max_total_items: usizeMaximum total count of container items:
sum(array_len) + sum(2 * map_pairs) across the entire decoded item
(maps count both keys and values).
max_array_len: usizeMaximum array length.
max_map_len: usizeMaximum map length (pairs).
max_bytes_len: usizeMaximum byte-string length (also applies to bignum magnitudes).
max_text_len: usizeMaximum text-string length in UTF-8 bytes.
Implementations§
Source§impl DecodeLimits
impl DecodeLimits
Sourcepub fn for_bytes(max_message_bytes: usize) -> Self
pub fn for_bytes(max_message_bytes: usize) -> Self
Construct conservative limits derived from a maximum message size.
The defaults are:
max_input_bytes = max_message_bytesmax_total_items = max_message_bytesmax_bytes_len = max_message_bytesmax_text_len = max_message_bytesmax_array_lenandmax_map_lenare capped byDEFAULT_MAX_CONTAINER_LEN
This is a pragmatic baseline. Production deployments should tune these explicitly.
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 · 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 DecodeLimits
impl Debug for DecodeLimits
Source§impl PartialEq for DecodeLimits
impl PartialEq for DecodeLimits
impl Copy for DecodeLimits
impl Eq for DecodeLimits
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