#[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
impl TjsonOptions
Sourcepub fn canonical() -> Self
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.
Sourcepub fn force_markers(self, force_markers: bool) -> Self
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.
Sourcepub fn bare_strings(self, bare_strings: BareStyle) -> Self
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.
Sourcepub fn bare_keys(self, bare_keys: BareStyle) -> Self
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.
Sourcepub fn inline_objects(self, inline_objects: bool) -> Self
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.
Sourcepub fn inline_arrays(self, inline_arrays: bool) -> Self
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.
Sourcepub fn string_array_style(self, string_array_style: StringArrayStyle) -> Self
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.
Sourcepub fn tables(self, tables: bool) -> Self
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.
Sourcepub fn wrap_width(self, wrap_width: Option<usize>) -> Self
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.
Sourcepub fn wrap_width_checked(
self,
wrap_width: Option<usize>,
) -> Result<Self, String>
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.
Sourcepub fn table_min_rows(self, table_min_rows: usize) -> Self
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.
Sourcepub fn table_min_cols(self, table_min_cols: usize) -> Self
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.
Sourcepub fn table_min_similarity(self, v: f32) -> Self
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.
Sourcepub fn table_column_max_width(
self,
table_column_max_width: Option<usize>,
) -> Self
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).
Sourcepub fn fold(self, style: FoldStyle) -> Self
pub fn fold(self, style: FoldStyle) -> Self
Set all four fold styles at once. Individual fold options override this if set after.
Sourcepub fn number_fold_style(self, style: FoldStyle) -> Self
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.
Sourcepub fn string_bare_fold_style(self, style: FoldStyle) -> Self
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.
Sourcepub fn string_quoted_fold_style(self, style: FoldStyle) -> Self
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.
Sourcepub fn string_multiline_fold_style(self, style: FoldStyle) -> Self
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.
Sourcepub fn table_fold(self, table_fold: bool) -> Self
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.
Sourcepub fn table_unindent_style(self, style: TableUnindentStyle) -> Self
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.
Sourcepub fn indent_glyph_style(self, style: IndentGlyphStyle) -> Self
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.
Sourcepub fn indent_glyph_marker_style(self, style: IndentGlyphMarkerStyle) -> Self
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.
Sourcepub fn multiline_strings(self, multiline_strings: bool) -> Self
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.
Sourcepub fn multiline_style(self, multiline_style: MultilineStyle) -> Self
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.
Sourcepub fn multiline_min_lines(self, multiline_min_lines: usize) -> Self
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.
Sourcepub fn multiline_max_lines(self, multiline_max_lines: usize) -> Self
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
impl Clone for TjsonOptions
Source§fn clone(&self) -> TjsonOptions
fn clone(&self) -> TjsonOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more