Skip to main content

Module print

Module print 

Source
Expand description

JSON printing.

Print is the entry point. pretty_print, inline_print and compact_print cover the common cases; print_with takes an Options for everything else — indentation, padding, and the width or item count at which an array or object is expanded onto several lines.

Printing is a two-pass process: sizes are precomputed (PrecomputeSize), then written out (PrintWithSize), so the layout decision for a nested value is known before it is emitted.

Strings are escaped per RFC 8785.

Structs§

IndentBy
An Indent repeated a given number of times, ready to be displayed.
Options
Print options.
Printed
Printed value.
Spaces
The given number of spaces, ready to be displayed.

Enums§

Indent
Indentation unit.
Limit
Threshold past which an array or object is expanded onto several lines.
Padding
Padding inserted between syntactic elements.
Size
The size of a value.

Traits§

PrecomputeSize
Computation of the printed layout, ahead of printing.
Print
Print methods.
PrintWithSize
Printing with precomputed sizes.

Functions§

pre_compute_array_size
Computes the printed size of an array made of items.
pre_compute_object_size
Computes the printed size of an object made of entries.
print_array
Writes items as a JSON array, using the layout at sizes[*index].
print_object
Writes entries as a JSON object, using the layout at sizes[*index].
printed_string_size
Returns the byte length of string literal according to RFC8785.
string_literal
Formats a string literal according to RFC8785.