pub struct WireLimits { /* private fields */ }Expand description
Shared limits applied to one complete wire decode.
Implementations§
Source§impl WireLimits
impl WireLimits
Sourcepub const DEFAULT_MAX_INPUT_BYTES: usize = 1_048_576
pub const DEFAULT_MAX_INPUT_BYTES: usize = 1_048_576
Default maximum complete JSON input length.
Sourcepub const DEFAULT_MAX_DEPTH: usize = 64
pub const DEFAULT_MAX_DEPTH: usize = 64
Default maximum recursive wire depth.
Sourcepub const DEFAULT_MAX_NODES: usize = 100_000
pub const DEFAULT_MAX_NODES: usize = 100_000
Default maximum decoded node count.
Sourcepub const DEFAULT_MAX_COLLECTION_ITEMS: usize = 4_096
pub const DEFAULT_MAX_COLLECTION_ITEMS: usize = 4_096
Default maximum elements in one collection.
Sourcepub const DEFAULT_MAX_MAP_ENTRIES: usize = 4_096
pub const DEFAULT_MAX_MAP_ENTRIES: usize = 4_096
Default maximum entries in one map.
Sourcepub const DEFAULT_MAX_STRING_BYTES: usize
pub const DEFAULT_MAX_STRING_BYTES: usize
Default maximum bytes in one decoded string.
Sourcepub const DEFAULT_MAX_NUMERIC_BYTES: usize = 4_096
pub const DEFAULT_MAX_NUMERIC_BYTES: usize = 4_096
Default maximum UTF-8 bytes in one decoded numeric representation.
Sourcepub const fn new(max_input_bytes: usize) -> Self
pub const fn new(max_input_bytes: usize) -> Self
Creates shared wire limits with the specified input-byte bound.
Sourcepub const fn with_max_depth(self, max_depth: usize) -> Self
pub const fn with_max_depth(self, max_depth: usize) -> Self
Sets the maximum recursive wire depth.
Sourcepub const fn with_max_nodes(self, max_nodes: usize) -> Self
pub const fn with_max_nodes(self, max_nodes: usize) -> Self
Sets the maximum decoded node count.
Sourcepub const fn with_max_collection_items(
self,
max_collection_items: usize,
) -> Self
pub const fn with_max_collection_items( self, max_collection_items: usize, ) -> Self
Sets the maximum elements in one collection.
Sourcepub const fn with_max_map_entries(self, max_map_entries: usize) -> Self
pub const fn with_max_map_entries(self, max_map_entries: usize) -> Self
Sets the maximum entries in one map.
Sourcepub const fn with_max_string_bytes(self, max_string_bytes: usize) -> Self
pub const fn with_max_string_bytes(self, max_string_bytes: usize) -> Self
Sets the maximum bytes in one decoded string.
Sourcepub const fn with_max_numeric_bytes(self, max_numeric_bytes: usize) -> Self
pub const fn with_max_numeric_bytes(self, max_numeric_bytes: usize) -> Self
Sets the maximum UTF-8 bytes in one decoded numeric representation.
Sourcepub const fn max_input_bytes(self) -> usize
pub const fn max_input_bytes(self) -> usize
Returns the maximum complete input length.
Sourcepub const fn max_collection_items(self) -> usize
pub const fn max_collection_items(self) -> usize
Returns the maximum elements in one collection.
Sourcepub const fn max_map_entries(self) -> usize
pub const fn max_map_entries(self) -> usize
Returns the maximum entries in one map.
Sourcepub const fn max_string_bytes(self) -> usize
pub const fn max_string_bytes(self) -> usize
Returns the maximum bytes in one decoded string.
Sourcepub const fn max_numeric_bytes(self) -> usize
pub const fn max_numeric_bytes(self) -> usize
Returns the maximum UTF-8 bytes in one decoded numeric representation.
Sourcepub fn begin(
self,
input_bytes: usize,
) -> Result<WireBudget, ValueWireDecodeError>
pub fn begin( self, input_bytes: usize, ) -> Result<WireBudget, ValueWireDecodeError>
Checks a complete input length and starts a shared accounting session.
Sourcepub fn begin_json(
self,
input: &[u8],
) -> Result<WireBudget, ValueWireDecodeError>
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.
Sourcepub const fn check_json_bytes(
self,
input_bytes: usize,
) -> Result<(), ValueWireDecodeError>
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
impl Clone for WireLimits
Source§fn clone(&self) -> WireLimits
fn clone(&self) -> WireLimits
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more