pub struct PrettifyConfig<'a> {
pub indent: &'a str,
pub max_line_width: usize,
pub max_inline_depth: usize,
pub max_inline_object_entries: usize,
pub max_inline_array_entries: usize,
pub inline_bracket_padding: bool,
pub parser: JsonParserConfig,
}Expand description
Configuration for prettify.
indent is the string emitted per nesting level (typically " " or
"\t"). parser controls the same leniency knobs as the rest of the
crate (trailing commas, comments, trailing data).
max_line_width enables single-line rendering of small containers. A
container is kept on one line when its compact form fits the width
remaining at its nesting depth (max_line_width - depth * indent.len()).
The in-line key prefix is not counted, so a long key may overshoot the
width. 0 (the default) always expands every container.
max_inline_depth caps how many container levels may stack on one inlined
line: the outermost inlined container is level 1, a container nested inside
it is level 2, and so on. A container is expanded if inlining it would
exceed this. This bounds the work of a single inline attempt and doubles as
a sizing knob. The default imposes no limit.
max_inline_object_entries and max_inline_array_entries bound inlining by
container size: an object with more keys (or an array with more elements)
than its cap is always expanded, even when its compact form fits the width.
0 keeps only the corresponding empty container inline. Both default to no
limit.
inline_bracket_padding inserts a space just inside the brackets of an
inlined container, rendering { "a": 1 } and [ 1, 2 ] instead of
{"a": 1} and [1, 2]. Empty containers stay tight and expanded output is
unaffected. The default is false.
Comments (when allowed) are dropped from the output. Unquoted field keys
are not supported by the prettifier and will return an error even if
allow_unquoted_field_keys is set on the parser config.
Fields§
§indent: &'a strIndent string emitted once per nesting level.
max_line_width: usizeApproximate target line width in bytes. 0 disables inlining.
max_inline_depth: usizeMaximum container nesting permitted on a single inlined line.
max_inline_object_entries: usizeMaximum object key count permitted on a single inlined line. 0 keeps
only empty objects inline.
max_inline_array_entries: usizeMaximum array element count permitted on a single inlined line. 0 keeps
only empty arrays inline.
inline_bracket_padding: boolPad the insides of inlined container brackets with a space. Empty containers are unaffected.
parser: JsonParserConfigParser configuration controlling leniency and recursion limits.
Implementations§
Source§impl<'a> PrettifyConfig<'a>
impl<'a> PrettifyConfig<'a>
pub const SMART: PrettifyConfig<'static>
Trait Implementations§
Source§impl<'a> Clone for PrettifyConfig<'a>
impl<'a> Clone for PrettifyConfig<'a>
Source§fn clone(&self) -> PrettifyConfig<'a>
fn clone(&self) -> PrettifyConfig<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more