Skip to main content

MAX_SPACE_SERIALIZE_DEPTH

Constant MAX_SPACE_SERIALIZE_DEPTH 

Source
pub const MAX_SPACE_SERIALIZE_DEPTH: usize = 128;
Expand description

Greatest space-nesting depth FuncSpace and Ops will serialize.

Both are trees, and serde cannot emit a tree without one native stack frame per level, so the depth has to be bounded somewhere: past it, the runtime aborts the process instead of raising a catchable panic (#1056). A space tree deeper than this fails serialization with an ordinary serializer error naming the limit.

The value matches the recursion limit serde_json’s Deserializer already imposes on the same documents, and is generous against both ends of that comparison. On the read side, a FuncSpace costs two JSON nesting levels (its object plus its spaces array), so parsing one of these documents back caps out near 61 levels — the emit limit is the more permissive of the two. On the source side, the deepest space nesting across the 14 450-file corpus under tests/repositories is 10 levels.