Skip to main content

PrettifyConfig

Struct PrettifyConfig 

Source
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 str

Indent string emitted once per nesting level.

§max_line_width: usize

Approximate target line width in bytes. 0 disables inlining.

§max_inline_depth: usize

Maximum container nesting permitted on a single inlined line.

§max_inline_object_entries: usize

Maximum object key count permitted on a single inlined line. 0 keeps only empty objects inline.

§max_inline_array_entries: usize

Maximum array element count permitted on a single inlined line. 0 keeps only empty arrays inline.

§inline_bracket_padding: bool

Pad the insides of inlined container brackets with a space. Empty containers are unaffected.

§parser: JsonParserConfig

Parser configuration controlling leniency and recursion limits.

Implementations§

Source§

impl<'a> PrettifyConfig<'a>

Source

pub const SMART: PrettifyConfig<'static>

Trait Implementations§

Source§

impl<'a> Clone for PrettifyConfig<'a>

Source§

fn clone(&self) -> PrettifyConfig<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for PrettifyConfig<'a>

Source§

impl Default for PrettifyConfig<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for PrettifyConfig<'a>

§

impl<'a> RefUnwindSafe for PrettifyConfig<'a>

§

impl<'a> Send for PrettifyConfig<'a>

§

impl<'a> Sync for PrettifyConfig<'a>

§

impl<'a> Unpin for PrettifyConfig<'a>

§

impl<'a> UnsafeUnpin for PrettifyConfig<'a>

§

impl<'a> UnwindSafe for PrettifyConfig<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.