pub struct Limits {
pub max_depth: usize,
pub max_items: usize,
pub max_string_bytes: usize,
pub max_object_keys: usize,
}Fields§
§max_depth: usizeThe validator recurses, so this is what protects the stack.
max_items: usize§max_string_bytes: usize§max_object_keys: usizeImplementations§
Source§impl Limits
impl Limits
Sourcepub const MAX_DEPTH: usize = 256
pub const MAX_DEPTH: usize = 256
The highest max_depth the engine will honour, whatever it is handed.
Both the JSON parser and the validator recurse, so depth is what stands
between a hostile document and the stack. A stack overflow is not a
panic that a binding can catch and turn into an error: it kills the
process, taking every other request in flight with it. Measured, that
starts happening somewhere between one and five thousand levels on the
object path, so a caller raising max_depth freely could disable the
one bound that is not recoverable.
256 is the value PERMISSIVE already used for trusted input, and it is
far past any document a person meant to send. A limit that can be
turned off until the process dies is not a limit.
pub const DEFAULT: Self
Sourcepub const PERMISSIVE: Self
pub const PERMISSIVE: Self
For trusted input. Depth stays bounded because the stack is.