#toml #convert #serializable #string #values #traits #converting

tomlconv

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

3 releases

Uses old Rust 2015

0.1.2 May 6, 2017
0.1.1 May 6, 2017
0.1.0 May 6, 2017

#44 in #serializable

Download history 3/week @ 2024-02-17 48/week @ 2024-02-24 4/week @ 2024-03-02 7/week @ 2024-03-09 2/week @ 2024-03-16 56/week @ 2024-03-30 7/week @ 2024-04-06

102 downloads per month

MIT license

10KB
132 lines

tomlconv

Build Status License: MIT

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

Documentation


lib.rs:

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);

Dependencies

~0.6–1.1MB
~19K SLoC