serde-double-tag
This crates provides derive macros for a double tagged enum representation for serde.
It is basically a combination of externally and adjecently tagged enums.
If you enable the schemars feature,
the crate also exposes a derive macro for the schemars::JsonSchema trait.
For example, consider this enum:
A Friend::Human will be serialized as:
Similarly, a Friend::Dog will be serialized as:
This enum representation could be useful if you want data for the different variants to co-exist in a single file or in your database. Since each variant uses a different field name, they will never conflict. And since there is still a separate field for the enum tag, you can still known which variant is actually active.
Currently supported serde attributes:
- `#[serde(rename = "...")]
- `#[serde(rename_all = "...")]
- `#[serde(rename_all_fields = "...")]
- `#[serde(deny_unknown_fields = "...")]