Crate serdeconv

source ·
Expand description

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

Structs

  • The error type for this crate.

Enums

Traits

  • This trait allows to convert JSON objects to deserializable values.
  • This trait allows to convert MessagePack binaries to deserializable values.
  • This trait allows to convert TOML objects to deserializable values.
  • This trait allows to convert serializable values to JSON objects.
  • This trait allows to convert serializable values to MessagePack binaries.
  • This trait allows to convert serializable values to TOML objects.

Functions

Type Definitions

  • A specialized Result type for this crate.