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 [ / { markers even for non-empty arrays and objects that would normally use implicit (marker-free) layout. Default is false.

Source

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

Controls whether string values are rendered bare (unquoted) when possible. Default is Prefer.

Source

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

Controls whether object keys are rendered bare (unquoted) when possible. 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 of short strings are packed. 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 < 10. 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: usize) -> Self

Maximum rendered width (in characters) of any single table column. Default is 40.

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 None.

Source

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

Fold style for bare strings. Default is Auto.

Source

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

Fold style for quoted strings. 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 applied. Default is Auto.

Source

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

Controls how the /< opening glyph is placed relative to its key. 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

Preferred multiline string rendering style. 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>,