Skip to main content

WireLimits

Struct WireLimits 

Source
pub struct WireLimits { /* private fields */ }
Expand description

Shared limits applied to one complete wire decode.

Implementations§

Source§

impl WireLimits

Source

pub const DEFAULT_MAX_INPUT_BYTES: usize = 1_048_576

Default maximum complete JSON input length.

Source

pub const DEFAULT_MAX_DEPTH: usize = 64

Default maximum recursive wire depth.

Source

pub const DEFAULT_MAX_NODES: usize = 100_000

Default maximum decoded node count.

Source

pub const DEFAULT_MAX_COLLECTION_ITEMS: usize = 4_096

Default maximum elements in one collection.

Source

pub const DEFAULT_MAX_MAP_ENTRIES: usize = 4_096

Default maximum entries in one map.

Source

pub const DEFAULT_MAX_STRING_BYTES: usize

Default maximum bytes in one decoded string.

Source

pub const DEFAULT_MAX_NUMERIC_BYTES: usize = 4_096

Default maximum UTF-8 bytes in one decoded numeric representation.

Source

pub const fn new(max_input_bytes: usize) -> Self

Creates shared wire limits with the specified input-byte bound.

Source

pub const fn with_max_depth(self, max_depth: usize) -> Self

Sets the maximum recursive wire depth.

Source

pub const fn with_max_nodes(self, max_nodes: usize) -> Self

Sets the maximum decoded node count.

Source

pub const fn with_max_collection_items( self, max_collection_items: usize, ) -> Self

Sets the maximum elements in one collection.

Source

pub const fn with_max_map_entries(self, max_map_entries: usize) -> Self

Sets the maximum entries in one map.

Source

pub const fn with_max_string_bytes(self, max_string_bytes: usize) -> Self

Sets the maximum bytes in one decoded string.

Source

pub const fn with_max_numeric_bytes(self, max_numeric_bytes: usize) -> Self

Sets the maximum UTF-8 bytes in one decoded numeric representation.

Source

pub const fn max_input_bytes(self) -> usize

Returns the maximum complete input length.

Source

pub const fn max_depth(self) -> usize

Returns the maximum recursive depth.

Source

pub const fn max_nodes(self) -> usize

Returns the maximum decoded node count.

Source

pub const fn max_collection_items(self) -> usize

Returns the maximum elements in one collection.

Source

pub const fn max_map_entries(self) -> usize

Returns the maximum entries in one map.

Source

pub const fn max_string_bytes(self) -> usize

Returns the maximum bytes in one decoded string.

Source

pub const fn max_numeric_bytes(self) -> usize

Returns the maximum UTF-8 bytes in one decoded numeric representation.

Source

pub fn begin( self, input_bytes: usize, ) -> Result<WireBudget, ValueWireDecodeError>

Checks a complete input length and starts a shared accounting session.

Source

pub fn begin_json( self, input: &[u8], ) -> Result<WireBudget, ValueWireDecodeError>

Preflights one complete JSON document before decoding its runtime representation, then starts a semantic accounting session.

The preflight validates complete-input size and JSON syntax while traversing the document without materializing a JSON tree. Runtime resource limits are charged by the returned budget after decoding so embedded protocol wrappers do not consume value-node or depth headroom.

§Errors

Returns an input-size or JSON syntax error before the caller deserializes its concrete wire DTO. Semantic resource errors are returned by the budget after the DTO has been materialized. Normal decode paths should use Self::begin and let their Serde decoder validate syntax once.

Source

pub const fn check_json_bytes( self, input_bytes: usize, ) -> Result<(), ValueWireDecodeError>

Checks a complete input length without starting an accounting session.

Trait Implementations§

Source§

impl Clone for WireLimits

Source§

fn clone(&self) -> WireLimits

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WireLimits

Source§

impl Debug for WireLimits

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WireLimits

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for WireLimits

Source§

impl Hash for WireLimits

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for WireLimits

Source§

fn eq(&self, other: &WireLimits) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for WireLimits

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoValueDefault<T> for T

Source§

fn into_value_default(self) -> T

Converts this argument into the default value. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.