#[non_exhaustive]pub struct PrettyConfig {Show 14 fields
pub depth_limit: usize,
pub new_line: Cow<'static, str>,
pub indentor: Cow<'static, str>,
pub separator: Cow<'static, str>,
pub struct_names: bool,
pub separate_tuple_members: bool,
pub enumerate_arrays: bool,
pub extensions: Extensions,
pub compact_arrays: bool,
pub escape_strings: bool,
pub compact_structs: bool,
pub compact_maps: bool,
pub number_suffixes: bool,
pub path_meta: Option<Field>,
}Expand description
Pretty serializer configuration.
§Examples
use ron::ser::PrettyConfig;
let my_config = PrettyConfig::new()
.depth_limit(4)
// definitely superior (okay, just joking)
.indentor("\t");Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.depth_limit: usizeLimit the pretty-ness up to the given depth.
new_line: Cow<'static, str>New line string
indentor: Cow<'static, str>Indentation string
separator: Cow<'static, str>Separator string
struct_names: bool§separate_tuple_members: boolSeparate tuple members with indentation
enumerate_arrays: boolEnumerate array items in comments
extensions: ExtensionsEnable extensions. Only configures implicit_some,
unwrap_newtypes, and unwrap_variant_newtypes for now.
compact_arrays: boolEnable compact arrays, which do not insert new lines and indentation between the elements of an array
escape_strings: boolWhether to serialize strings as escaped strings, or fall back onto raw strings if necessary.
compact_structs: boolEnable compact structs, which do not insert new lines and indentation between the fields of a struct
compact_maps: boolEnable compact maps, which do not insert new lines and indentation between the entries of a struct
number_suffixes: boolEnable explicit number type suffixes like 1u16
path_meta: Option<Field>Additional path-based field metadata to serialize
Implementations§
Source§impl PrettyConfig
impl PrettyConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a default PrettyConfig.
Sourcepub fn depth_limit(self, depth_limit: usize) -> Self
pub fn depth_limit(self, depth_limit: usize) -> Self
Limits the pretty-formatting based on the number of indentations. I.e., with a depth limit of 5, starting with an element of depth (indentation level) 6, everything will be put into the same line, without pretty formatting.
Default: usize::MAX
Sourcepub fn new_line(self, new_line: impl Into<Cow<'static, str>>) -> Self
pub fn new_line(self, new_line: impl Into<Cow<'static, str>>) -> Self
Configures the newlines used for serialization.
Default: \r\n on Windows, \n otherwise
Sourcepub fn indentor(self, indentor: impl Into<Cow<'static, str>>) -> Self
pub fn indentor(self, indentor: impl Into<Cow<'static, str>>) -> Self
Configures the string sequence used for indentation.
Default: 4 spaces
Sourcepub fn separator(self, separator: impl Into<Cow<'static, str>>) -> Self
pub fn separator(self, separator: impl Into<Cow<'static, str>>) -> Self
Configures the string sequence used to separate items inline.
Default: 1 space
Sourcepub fn struct_names(self, struct_names: bool) -> Self
pub fn struct_names(self, struct_names: bool) -> Self
Configures whether to emit struct names.
See also Extensions::EXPLICIT_STRUCT_NAMES for the extension equivalent.
Default: false
Sourcepub fn separate_tuple_members(self, separate_tuple_members: bool) -> Self
pub fn separate_tuple_members(self, separate_tuple_members: bool) -> Self
Configures whether tuples are single- or multi-line.
If set to true, tuples will have their fields indented and in new
lines. If set to false, tuples will be serialized without any
newlines or indentations.
Default: false
Sourcepub fn enumerate_arrays(self, enumerate_arrays: bool) -> Self
pub fn enumerate_arrays(self, enumerate_arrays: bool) -> Self
Configures whether a comment shall be added to every array element, indicating the index.
Default: false
Sourcepub fn compact_arrays(self, compact_arrays: bool) -> Self
pub fn compact_arrays(self, compact_arrays: bool) -> Self
Configures whether every array should be a single line (true)
or a multi line one (false).
When false, ["a","b"] will serialize to
[
"a",
"b",
]When true, ["a","b"] will instead serialize to
["a","b"]Default: false
Sourcepub fn extensions(self, extensions: Extensions) -> Self
pub fn extensions(self, extensions: Extensions) -> Self
Configures extensions
Default: Extensions::empty()
Sourcepub fn escape_strings(self, escape_strings: bool) -> Self
pub fn escape_strings(self, escape_strings: bool) -> Self
Configures whether strings should be serialized using escapes (true)
or fall back to raw strings if the string contains a " (false).
When true, "a\nb" will serialize to
"a\nb"When false, "a\nb" will instead serialize to
"a
b"Default: true
Sourcepub fn compact_structs(self, compact_structs: bool) -> Self
pub fn compact_structs(self, compact_structs: bool) -> Self
Sourcepub fn compact_maps(self, compact_maps: bool) -> Self
pub fn compact_maps(self, compact_maps: bool) -> Self
Sourcepub fn number_suffixes(self, number_suffixes: bool) -> Self
pub fn number_suffixes(self, number_suffixes: bool) -> Self
Configures whether numbers should be printed without (false) or
with (true) their explicit type suffixes.
When false, the integer 12345u16 will serialize to
12345and the float 12345.6789f64 will serialize to
12345.6789When true, the integer 12345u16 will serialize to
12345u16and the float 12345.6789f64 will serialize to
12345.6789f64Default: false
Trait Implementations§
Source§impl Clone for PrettyConfig
impl Clone for PrettyConfig
Source§fn clone(&self) -> PrettyConfig
fn clone(&self) -> PrettyConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more