#toml #json #messagepack

serdeconv

This crate provides convenient traits and functions for converting between TOML/JSON/MessagePack strings and serializable values

4 releases (2 breaking)

Uses old Rust 2015

0.4.0 May 5, 2020
0.3.0 Jun 15, 2017
0.2.1 May 14, 2017
0.2.0 May 6, 2017

#5 in #messagepack

Download history 107/week @ 2021-02-26 52/week @ 2021-03-05 37/week @ 2021-03-12 59/week @ 2021-03-19 74/week @ 2021-03-26 47/week @ 2021-04-02 55/week @ 2021-04-09 143/week @ 2021-04-16 82/week @ 2021-04-23 121/week @ 2021-04-30 56/week @ 2021-05-07 46/week @ 2021-05-14 40/week @ 2021-05-21 87/week @ 2021-05-28 75/week @ 2021-06-04 67/week @ 2021-06-11

328 downloads per month
Used in less than 7 crates

MIT license

20KB
336 lines

serdeconv

Crates.io: serdeconv Build Status License: MIT

This crate provides convenient traits and functions for converting between TOML/JSON/MessagePack strings and serializable values.

This is highly depends on the serde crate.

Documentation


lib.rs:

This crate provides convenient traits and functions for converting between TOML/JSON/MessagePack strings and serializable values.

This is highly depends on the serde crate.

Examples

Converts from a TOML string to a serializable value:

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 {}

# fn main() {
// 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

~1.4–2.2MB
~48K SLoC