[go: up one dir, main page]

Crate tomlconv

Source
Expand description

This crate provides convenient traits and functions for converting between TOML and serializable values.

§Examples

Converts from a TOML string to a serializable value:

extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate tomlconv;

use tomlconv::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);

Enums§

ErrorKind
A list of error kinds.

Traits§

FromToml
This trait allows to convert TOML objects to deserializable values.
ToToml
This trait allows to convert serializable values to TOML objects.

Functions§

from_toml
Converts from the TOML value to an instance of T.
from_toml_file
Converts from the TOML file to an instance of T.
from_toml_reader
Reads a TOML string from the reader and converts it to an instance of T.
from_toml_str
Converts from the TOML string to an instance of T.
to_toml
Converts the value to a TOML value.
to_toml_file
Converts the value to a TOML string and writes it to the speficied file.
to_toml_string
Converts the value to a TOML string.
to_toml_writer
Converts the value to a TOML string and writes it to the writer.

Type Aliases§

Error
The error type for this crate.
Result
A specialized Result type for this crate.