#[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: usize
Limit 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: bool
Separate tuple members with indentation
enumerate_arrays: bool
Enumerate array items in comments
extensions: Extensions
Enable extensions. Only configures implicit_some
,
unwrap_newtypes
, and unwrap_variant_newtypes
for now.
compact_arrays: bool
Enable compact arrays, which do not insert new lines and indentation between the elements of an array
escape_strings: bool
Whether to serialize strings as escaped strings, or fall back onto raw strings if necessary.
compact_structs: bool
Enable compact structs, which do not insert new lines and indentation between the fields of a struct
compact_maps: bool
Enable compact maps, which do not insert new lines and indentation between the entries of a struct
number_suffixes: bool
Enable 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() -> PrettyConfig
pub fn new() -> PrettyConfig
Creates a default PrettyConfig
.
Sourcepub fn depth_limit(self, depth_limit: usize) -> PrettyConfig
pub fn depth_limit(self, depth_limit: usize) -> PrettyConfig
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>>) -> PrettyConfig
pub fn new_line(self, new_line: impl Into<Cow<'static, str>>) -> PrettyConfig
Configures the newlines used for serialization.
Default: \r\n
on Windows, \n
otherwise
Sourcepub fn indentor(self, indentor: impl Into<Cow<'static, str>>) -> PrettyConfig
pub fn indentor(self, indentor: impl Into<Cow<'static, str>>) -> PrettyConfig
Configures the string sequence used for indentation.
Default: 4 spaces
Sourcepub fn separator(self, separator: impl Into<Cow<'static, str>>) -> PrettyConfig
pub fn separator(self, separator: impl Into<Cow<'static, str>>) -> PrettyConfig
Configures the string sequence used to separate items inline.
Default: 1 space
Sourcepub fn struct_names(self, struct_names: bool) -> PrettyConfig
pub fn struct_names(self, struct_names: bool) -> PrettyConfig
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,
) -> PrettyConfig
pub fn separate_tuple_members( self, separate_tuple_members: bool, ) -> PrettyConfig
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) -> PrettyConfig
pub fn enumerate_arrays(self, enumerate_arrays: bool) -> PrettyConfig
Configures whether a comment shall be added to every array element, indicating the index.
Default: false
Sourcepub fn compact_arrays(self, compact_arrays: bool) -> PrettyConfig
pub fn compact_arrays(self, compact_arrays: bool) -> PrettyConfig
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) -> PrettyConfig
pub fn extensions(self, extensions: Extensions) -> PrettyConfig
Configures extensions
Default: Extensions::empty()
Sourcepub fn escape_strings(self, escape_strings: bool) -> PrettyConfig
pub fn escape_strings(self, escape_strings: bool) -> PrettyConfig
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) -> PrettyConfig
pub fn compact_structs(self, compact_structs: bool) -> PrettyConfig
Sourcepub fn compact_maps(self, compact_maps: bool) -> PrettyConfig
pub fn compact_maps(self, compact_maps: bool) -> PrettyConfig
Sourcepub fn number_suffixes(self, number_suffixes: bool) -> PrettyConfig
pub fn number_suffixes(self, number_suffixes: bool) -> PrettyConfig
Configures whether numbers should be printed without (false
) or
with (true
) their explicit type suffixes.
When false
, the integer 12345u16
will serialize to
12345
and the float 12345.6789f64
will serialize to
12345.6789
When true
, the integer 12345u16
will serialize to
12345u16
and the float 12345.6789f64
will serialize to
12345.6789f64
Default: 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 moreSource§impl Debug for PrettyConfig
impl Debug for PrettyConfig
Source§impl Default for PrettyConfig
impl Default for PrettyConfig
Source§fn default() -> PrettyConfig
fn default() -> PrettyConfig
Source§impl<'de> Deserialize<'de> for PrettyConfigwhere
PrettyConfig: Default,
impl<'de> Deserialize<'de> for PrettyConfigwhere
PrettyConfig: Default,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PrettyConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PrettyConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for PrettyConfig
impl PartialEq for PrettyConfig
Source§impl Serialize for PrettyConfig
impl Serialize for PrettyConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for PrettyConfig
impl StructuralPartialEq for PrettyConfig
Auto Trait Implementations§
impl Freeze for PrettyConfig
impl RefUnwindSafe for PrettyConfig
impl Send for PrettyConfig
impl Sync for PrettyConfig
impl Unpin for PrettyConfig
impl UnwindSafe for PrettyConfig
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using default()
.
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more