pub struct JsonOptions {
pub int_enums: BTreeMap<String, Vec<EnumPatch>>,
}Expand description
Options for handling enum JSON encodings.
Some enums are encoded as integers, while others are encoded as strings, and the type information alone is not always sufficient to recover which encoding should be used. For this reason, callers can whitelist ADT names that should be represented as integers in JSON. This applies to both encoding and decoding.
Additionally, older generated type metadata may have missing/incorrect discriminants. To keep
JSON conversion behavior aligned with external serde-based encodings, callers can provide
per-variant integer patches via EnumPatch.
Fields§
§int_enums: BTreeMap<String, Vec<EnumPatch>>Implementations§
Source§impl JsonOptions
impl JsonOptions
Sourcepub fn add_int_enum(&mut self, name: &str)
pub fn add_int_enum(&mut self, name: &str)
Register the name of an ADT enum that should be encoded as integers, rather than strings.
This only has an effect for unit variants.
Sourcepub fn add_int_enum_with_patches(&mut self, name: &str, patches: Vec<EnumPatch>)
pub fn add_int_enum_with_patches(&mut self, name: &str, patches: Vec<EnumPatch>)
Register an ADT enum for integer encoding, with explicit discriminant patches.
This only has an effect for unit variants.
Trait Implementations§
Source§impl Clone for JsonOptions
impl Clone for JsonOptions
Source§fn clone(&self) -> JsonOptions
fn clone(&self) -> JsonOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more