Skip to main content

TjsonOptions

Struct TjsonOptions 

Source
#[non_exhaustive]
pub struct TjsonOptions { /* private fields */ }
Expand description

Options controlling how TJSON is rendered. Use TjsonOptions::default for sensible defaults, or TjsonOptions::canonical for a compact, diff-friendly format. All fields are set via builder methods.

Implementations§

Source§

impl TjsonOptions

Source

pub fn canonical() -> Self

Returns options that produce canonical TJSON: one key-value pair per line, no inline packing, no tables, no multiline strings, no folding.

Source

pub fn force_markers(self, force_markers: bool) -> Self

When true, force explicit [ / { indent markers even for a only a single n+2 indent jump at a time, that would normally have an implicit indent marker. Normally, we only use markers when we jump at least two indent steps at once (n+2, n+2 again). Default is false.

Source

pub fn bare_strings(self, bare_strings: BareStyle) -> Self

Controls whether string values use bare string format or JSON quoted strings. Prefer uses bare strings whenever the spec permits; None always uses JSON quoted strings. Default is Prefer.

Source

pub fn bare_keys(self, bare_keys: BareStyle) -> Self

Controls whether object keys use bare key format or JSON quoted strings. Prefer uses bare keys whenever the spec permits; None always uses JSON quoted strings. Default is Prefer.

Source

pub fn inline_objects(self, inline_objects: bool) -> Self

When true, pack small objects onto a single line when they fit within wrap_width. Default is true.

Source

pub fn inline_arrays(self, inline_arrays: bool) -> Self

When true, pack small arrays onto a single line when they fit within wrap_width. Default is true.

Source

pub fn string_array_style(self, string_array_style: StringArrayStyle) -> Self

Controls how arrays where every element is a string are packed onto a single line. Has no effect on arrays that contain any non-string values. Default is PreferComma.

Source

pub fn tables(self, tables: bool) -> Self

When true, render homogeneous arrays of objects as pipe tables when they meet the minimum row, column, and similarity thresholds. Default is true.

Source

pub fn wrap_width(self, wrap_width: Option<usize>) -> Self

Set the wrap width. None means no wrap limit (infinite width). Values below 20 are clamped to 20 — use wrap_width_checked if you want an error instead.

Source

pub fn wrap_width_checked( self, wrap_width: Option<usize>, ) -> Result<Self, String>

Set the wrap width with validation. None means no wrap limit (infinite width). Returns an error if the value is Some(n) where n < 20. Use wrap_width if you want clamping instead.

Source

pub fn table_min_rows(self, table_min_rows: usize) -> Self

Minimum number of data rows an array must have to be rendered as a table. Default is 3.

Source

pub fn table_min_cols(self, table_min_cols: usize) -> Self

Minimum number of columns a table must have to be rendered as a pipe table. Default is 3.

Source

pub fn table_min_similarity(self, v: f32) -> Self

Minimum cell-fill fraction required for table rendering. Computed as filled_cells / (rows × columns) where filled_cells is the count of (row, column) pairs where the row’s object actually has that key. A value of 1.0 requires every row to have every column; 0.0 allows fully sparse tables. Range 0.0–1.0; default is 0.8.

Source

pub fn table_column_max_width( self, table_column_max_width: Option<usize>, ) -> Self

If any column’s content width (including the leading space on bare string values) exceeds this value, the table is abandoned entirely and falls back to block layout. None means no limit. Default is Some(40).

Source

pub fn fold(self, style: FoldStyle) -> Self

Set all four fold styles at once. Individual fold options override this if set after.

Source

pub fn number_fold_style(self, style: FoldStyle) -> Self

Fold style for numbers. Auto folds before ./e/E first, then between digits. Fixed folds between any two digits at the wrap limit. Default is Auto.

Source

pub fn string_bare_fold_style(self, style: FoldStyle) -> Self

Whether and how to fold long bare strings and bare keys across lines using / continuation markers. Applies to both string values and object keys rendered in bare format. Default is Auto.

Source

pub fn string_quoted_fold_style(self, style: FoldStyle) -> Self

Whether and how to fold long quoted strings and quoted keys across lines using / continuation markers. Applies to both string values and object keys rendered in JSON quoted format. Default is Auto.

Source

pub fn string_multiline_fold_style(self, style: FoldStyle) -> Self

Fold style within ` and `` multiline string bodies. Default is None.

Note: ``` (Transparent) multilines cannot fold regardless of this setting — the spec does not allow / continuations inside triple-backtick blocks.

Source

pub fn table_fold(self, table_fold: bool) -> Self

When true, emit \ fold continuations for wide table cells. Off by default — the spec notes that table folds are almost always a bad idea.

Source

pub fn table_unindent_style(self, style: TableUnindentStyle) -> Self

Controls table horizontal repositioning via /< /> indent-offset glyphs. Default is Auto.

Note: indent_glyph_style must not be None for glyphs to appear — table_unindent_style decides when to unindent; indent_glyph_style decides whether glyphs are permitted at all.

Source

pub fn indent_glyph_style(self, style: IndentGlyphStyle) -> Self

Controls when /< / /> indent-offset glyphs are emitted to push deeply-indented content back toward the left margin, improving readability at high nesting depths. Default is Auto.

Source

pub fn indent_glyph_marker_style(self, style: IndentGlyphMarkerStyle) -> Self

Controls whether the /< opening glyph trails its key on the same line (Compact) or appears on its own line (Separate). Default is Compact.

Source

pub fn multiline_strings(self, multiline_strings: bool) -> Self

When true, render strings containing newlines using multiline syntax (`, ``, or ```). When false, all strings are rendered as JSON strings. Default is true.

Source

pub fn multiline_style(self, multiline_style: MultilineStyle) -> Self

Selects the multiline string format: minimal (`), bold (``), or transparent (```), each with different body positioning and fallback rules. See MultilineStyle for the full breakdown. Default is Bold.

Source

pub fn multiline_min_lines(self, multiline_min_lines: usize) -> Self

Minimum number of newlines a string must contain to be rendered as multiline. 0 is treated as 1. Default is 1.

Source

pub fn multiline_max_lines(self, multiline_max_lines: usize) -> Self

Maximum number of content lines before Floating falls back to Bold. 0 means no limit. Default is 10.

Trait Implementations§

Source§

impl Clone for TjsonOptions

Source§

fn clone(&self) -> TjsonOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TjsonOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TjsonOptions

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for TjsonOptions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for TjsonOptions

Source§

fn eq(&self, other: &TjsonOptions) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for TjsonOptions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TjsonOptions

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,