ce86f351d6
I have had a good experience with this pattern in many of my other libraries.
44 lines
773 B
Rust
44 lines
773 B
Rust
use serde::Deserialize;
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct Nested;
|
|
|
|
#[derive(Deserialize)]
|
|
pub enum ExternallyTagged {
|
|
Flatten {
|
|
#[serde(flatten)]
|
|
nested: Nested,
|
|
string: &'static str,
|
|
},
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
#[serde(tag = "tag")]
|
|
pub enum InternallyTagged {
|
|
Flatten {
|
|
#[serde(flatten)]
|
|
nested: Nested,
|
|
string: &'static str,
|
|
},
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
#[serde(tag = "tag", content = "content")]
|
|
pub enum AdjacentlyTagged {
|
|
Flatten {
|
|
#[serde(flatten)]
|
|
nested: Nested,
|
|
string: &'static str,
|
|
},
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
#[serde(untagged)]
|
|
pub enum UntaggedWorkaround {
|
|
Flatten {
|
|
#[serde(flatten)]
|
|
nested: Nested,
|
|
string: &'static str,
|
|
},
|
|
}
|