pub struct Config {
pub delimiter: u8,
pub key_folding: bool,
pub flatten_depth: Option<usize>,
pub empty_array_bare: bool,
pub escape_controls: bool,
pub max_depth: usize,
pub max_input_bytes: usize,
}Expand description
Encoder configuration matching TOON spec v3.1 options.
Fields§
§delimiter: u8Delimiter between array/tabular values. Must be ,, \t, or |.
key_folding: boolIf true, fold single-key object chains into dot-notation keys (safe mode).
flatten_depth: Option<usize>Max fold depth (segments). None = unlimited. 0 disables folding.
empty_array_bare: boolIf true (v3.1), emit empty arrays as canonical [] / key: []
instead of the legacy [0]: / key[0]: length-marker form.
escape_controls: boolIf true (v3.1), escape control chars U+0000–U+001F (except the named
\n \r \t) as \uXXXX with lowercase hex.
max_depth: usizeMax JSON nesting depth. Input deeper than this is rejected before parsing, so neither the sonic-rs DOM parser nor the recursive emitter can overflow the stack (both crash the host process near depth ~50k). 0 disables the check — use only when the input’s depth is already bounded by the producer (e.g. orjson output, capped by CPython’s recursion limit), since the pre-scan is then redundant.
max_input_bytes: usizeMax input size in bytes. 0 disables the check (default). A caller that encodes untrusted input can set this to bound peak memory.