pub struct CodecOptions {
pub recursion_limit: usize,
}Expand description
Fields§
§recursion_limit: usizeHow deeply decoding will recurse before giving up. Defaults to 64,
matching the C++ codec’s maxNestingDepth.
Decoding is recursive, so without a bound, deeply nested input exhausts
the stack and aborts the process — which is not a catchable error in
Rust. The limit turns that into an ordinary Err.
It bounds two things: the nesting depth of the JSON itself, and the depth of the walk over the schema. The second is not implied by the first, because a struct that flattens a field of its own type recurses on the schema without descending into the JSON at all.
A limit of N admits N nested arrays or objects. Scalars do not count
against it, so the boundary is the same one the C++ codec applies at the
same numeric setting.
Raising this reintroduces the crash it exists to prevent. The safe ceiling depends on your build profile and the stack size of the thread doing the decoding; measured on a 1 MiB stack, decoding survived depth 1600 in release but overflowed at depth 200 in debug. The default is comfortably safe in both. Lowering it is always safe.
Trait Implementations§
Source§impl Clone for CodecOptions
impl Clone for CodecOptions
Source§fn clone(&self) -> CodecOptions
fn clone(&self) -> CodecOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more