如何在Serde中表达此TOML格式

时间:2019-03-20 17:56:06

标签: rust serde toml

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

0 个答案:

没有答案