pub struct ParseOptions {
pub max_key_len: usize,
pub max_collection_elements: usize,
pub max_bulk_string_len: usize,
pub max_depth: usize,
pub max_total_items: usize,
}Expand description
Configuration options for RESP value parsing.
These options allow customizing the DoS protection limits for different deployment scenarios. More restrictive limits provide better protection against resource exhaustion attacks.
Fields§
§max_key_len: usizeMaximum key length in bytes.
max_collection_elements: usizeMaximum number of elements in a single collection.
max_bulk_string_len: usizeMaximum size of a bulk string in bytes.
max_depth: usizeMaximum nesting depth for recursive structures.
max_total_items: usizeMaximum total items across all collections in a single parse.
This is the critical limit for preventing exponential allocation attacks from nested collections. Without this, an attacker could send nested arrays where total items = max_collection_elements^max_depth.
Implementations§
Source§impl ParseOptions
impl ParseOptions
Sourcepub const fn max_key_len(self, len: usize) -> Self
pub const fn max_key_len(self, len: usize) -> Self
Set the maximum key length.
Sourcepub const fn max_collection_elements(self, count: usize) -> Self
pub const fn max_collection_elements(self, count: usize) -> Self
Set the maximum collection element count.
Sourcepub const fn max_bulk_string_len(self, len: usize) -> Self
pub const fn max_bulk_string_len(self, len: usize) -> Self
Set the maximum bulk string length.
Sourcepub const fn max_total_items(self, count: usize) -> Self
pub const fn max_total_items(self, count: usize) -> Self
Set the maximum total items across all collections.
Trait Implementations§
Source§impl Clone for ParseOptions
impl Clone for ParseOptions
Source§fn clone(&self) -> ParseOptions
fn clone(&self) -> ParseOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more