Skip to main content

JsonSerialize

Trait JsonSerialize 

Source
pub trait JsonSerialize: Serialize { }
Available on crate feature json only.
Expand description

Marker bound for message types the JSON codec can serialize.

When the json feature is enabled this is exactly serde::Serialize: if a bound such as T: Message + JsonSerialize fails to hold, derive serde::Serialize on T (generated code does this unless you pass the codegen no_json option). When the feature is disabled it is an empty bound satisfied by every type, so proto-only message types generated without serde derives still qualify and the JSON codec is simply unavailable at runtime.

Auto-implemented for every qualifying type — do not implement it manually.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§