[−][src]Trait serdeconv::FromToml
This trait allows to convert TOML objects to deserializable values.
Examples
extern crate serde; #[macro_use] extern crate serde_derive; extern crate serdeconv; use serdeconv::FromToml; // Defines a deserializable struct. #[derive(Deserialize)] struct Foo { bar: String, baz: usize } impl FromToml for Foo {} // Converts from the TOML string to a `Foo` value. let toml = r#" bar = "aaa" baz = 123 "#; let foo = Foo::from_toml_str(toml).unwrap(); assert_eq!(foo.bar, "aaa"); assert_eq!(foo.baz, 123);
Provided methods
fn from_toml_file<P: AsRef<Path>>(path: P) -> Result<Self>
Converts from the TOML file to an instance of this implementation.
fn from_toml_reader<R: Read>(reader: R) -> Result<Self>
Reads a TOML string from the reader and converts it to an instance of this implementation.
fn from_toml_str(toml: &str) -> Result<Self>
Converts from the TOML string to an instance of this implementation.
fn from_toml_slice(toml: &[u8]) -> Result<Self>
Converts from the TOML bytes to an instance of this implementation.