0

我有一个可以反序列化的 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 中表达这一点?

4

0 回答 0