我有一个可以反序列化的Rust结构:
pub struct ProcessReference {
pub alias: Name,
pub source: String,
#[serde(rename = "input")]
pub initializations: Option<HashMap<String, JsonValue>>,
}
其中input
是可选的。这接受TOML格式:
[[process]]
alias = "other"
source = "other.toml"
或
[[process]]
alias = "other"
source = "other.toml"
input.input1 = 1
我希望input
可以扩展为第二个值,而不仅仅是JsonValue
,这样它也可以反序列化:
[[process]]
alias = "other"
source = "other.toml"
input.input1 = {1, true}
类似于Cargo用于依赖项的内容:
[dependencies]
flowrlib = { path = "../flowrlib", version = "~0.7.0" }
yaml-rust = "~0.3.5"
我该如何在Serde中表达这一点?