pub enum SkipSerialization {
Never,
Null(bool),
Empty(bool),
}
Expand description
Defines behavior for skipping the serialization of fields.
This behavior is configured via the skip_serialization
attribute on fields of structs. It is
passed as parameter to ToValue::skip_serialization
of the corresponding field.
The default for fields in derived structs is SkipSerialization::Null(true)
, which will skips
null
values under the field recursively. Newtype structs (MyType(T)
) and enums pass through
to their inner type and variant, respectively.
§Example
#[derive(Debug, Empty, ToValue)]
struct Helper {
#[metastructure(skip_serialization = "never")]
items: Annotated<Array<String>>,
}
Variants§
Never
Serialize all values. Missing values will be serialized as null
.
Null(bool)
Do not serialize null
values but keep empty collections.
If the bool
flag is set to true
, this applies to all descendants recursively; if it is
set to false
, this only applies to direct children and does not propagate down.
Empty(bool)
Do not serialize empty objects as indicated by the Empty
trait.
If the bool
flag is set to true
, this applies to all descendants recursively; if it is
set to false
, this only applies to direct children and does not propagate down.
Implementations§
Trait Implementations§
Source§impl Clone for SkipSerialization
impl Clone for SkipSerialization
Source§fn clone(&self) -> SkipSerialization
fn clone(&self) -> SkipSerialization
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more