Available on crate features
parse and toml only.Expand description
serde TOML integration via the toml crate
Since serde derives requires linking with serde crate,
you have to add it to your Cargo.toml:
[dependencies]
serde = "1"use cu::pre::*; // with `serde` feature, Serialize and Deserialize are
// part of the prelude
use std::collections::BTreeMap;
#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct FooBar {
foo: BTreeMap<String, String>,
}
// the toml macro and toml module will also be part of the prelude
let value1 = toml! {
[foo]
bar = "biz"
};
assert_eq!(value1["foo"]["bar"], "biz".into());
let value2: FooBar = toml::parse(r#"
[foo]
bar = "biz"
"#)?;
assert_eq!(
Some("biz"),
value2.foo.get("bar").map(|x| x.as_str()),
);
Structs§
- Date
- A parsed TOML date value
- Datetime
- A parsed TOML datetime value
- Spanned
- A spanned value, indicating the range at which it is defined in the source.
- Time
- A parsed TOML time value
- Toml
- TOML parse delegate. See
toml
Enums§
Functions§
- co_read
coroutine - Parse value from an async reader that yields TOML
- parse
- Parse value from a TOML
&str - read
- Parse value from a reader that yields TOML
- stringify
- Convert the value to a TOML string
- stringify_
pretty - Convert the value to a pretty-formatted TOML string