pub struct SerializeOptions { /* private fields */ }
Available on crate feature serde only.
Expand description

Options to control serialization of messages.

Used by DynamicMessage::serialize_with_options().

Implementations§

Creates a new instance of SerializeOptions, with the default options chosen to conform to the standard JSON mapping.

Whether to encode 64-bit integral types as strings.

The spec requires encoding 64-bit integers as strings, to prevent loss of precision in JSON when the value cannot be represented exactly by a double. If this option is disabled, all numbers will be serialized as their corresponding serde types instead.

The default value is true.

Whether to encode enum values as their numeric value.

If true, enum values will be serialized as their integer values. Otherwise, they will be serialized as the string value specified in the proto file.

The default value is false.

Whether to use the proto field name instead of the lowerCamelCase name in JSON field names.

The default value is false.

Whether to skip fields which have their default value.

If true, any fields for which has_field returns false will not be serialized. If false, they will be serialized with their default value.

The default value is true.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.