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§
- Error
- The error type for this crate.
Enums§
- Error
Kind - A list of error kinds.
Traits§
- From
Json - This trait allows to convert JSON objects to deserializable values.
- From
MsgPack - This trait allows to convert MessagePack binaries to deserializable values.
- From
Toml - This trait allows to convert TOML objects to deserializable values.
- ToJson
- This trait allows to convert serializable values to JSON objects.
- ToMsg
Pack - This trait allows to convert serializable values to MessagePack binaries.
- ToToml
- This trait allows to convert serializable values to TOML objects.
Functions§
- from_
json_ file - Converts from the JSON file to a value of
T
type. - from_
json_ reader - Reads a JSON string from the reader and converts it to a value of
T
type. - from_
json_ slice - Converts from the JSON bytes to a value of
T
type. - from_
json_ str - Converts from the JSON string to a value of
T
type. - from_
msgpack_ file - Converts from the MessagePack file to a value of
T
type. - from_
msgpack_ reader - Reads a MessagePack bytes from the reader and converts it to a value of
T
type. - from_
msgpack_ slice - Converts from the MessagePack bytes to a value of
T
type. - from_
toml_ file - Converts from the TOML file to a value of
T
type. - from_
toml_ reader - Reads a TOML string from the reader and converts it to a value of
T
type. - from_
toml_ slice - Converts from the TOML bytes to a value of
T
type. - from_
toml_ str - Converts from the TOML string to a value of
T
type. - to_
json_ file - Converts the value to a JSON string and writes it to the speficied file.
- to_
json_ string - Converts the value to a JSON string.
- to_
json_ string_ pretty - Converts the value to a pretty printed JSON string.
- to_
json_ writer - Converts the value to a JSON string and writes it to the writer.
- to_
json_ writer_ pretty - Converts the value to a pretty printed JSON string and writes it to the writer.
- to_
msgpack_ file - Converts the value to a MessagePack bytes and writes it to the speficied file.
- to_
msgpack_ vec - Converts the value to a MessagePack bytes.
- to_
msgpack_ writer - Converts the value to a MessagePack bytes and writes it to the writer.
- 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§
- Result
- A specialized
Result
type for this crate.