#toml #json #messagepack

serdeconv

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

5 unstable releases

Uses old Rust 2015

0.4.1 Mar 31, 2023
0.4.0 May 5, 2020
0.3.0 Jun 15, 2017
0.2.1 May 14, 2017
0.2.0 May 6, 2017

#1354 in Encoding

Download history 299/week @ 2023-11-03 311/week @ 2023-11-10 302/week @ 2023-11-17 434/week @ 2023-11-24 284/week @ 2023-12-01 397/week @ 2023-12-08 341/week @ 2023-12-15 316/week @ 2023-12-22 245/week @ 2023-12-29 395/week @ 2024-01-05 391/week @ 2024-01-12 336/week @ 2024-01-19 344/week @ 2024-01-26 374/week @ 2024-02-02 321/week @ 2024-02-09 304/week @ 2024-02-16

1,381 downloads per month
Used in 6 crates

MIT license

21KB
343 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 {}

// 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

~2–2.7MB
~59K SLoC