1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! This crate provides convenient traits and functions
//! for converting between TOML/JSON/MessagePack strings and serializable values.
//!
//! This is highly depends on the [serde](https://github.com/serde-rs/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);
//! # }
//! ```
#![warn(missing_docs)]
extern crate rmp_serde;
extern crate serde;
extern crate serde_json;
extern crate toml;
#[macro_use]
extern crate trackable;

pub use convert_json::{from_json_file, from_json_reader, from_json_slice, from_json_str};
pub use convert_json::{
    to_json_file, to_json_string, to_json_string_pretty, to_json_writer, to_json_writer_pretty,
};
pub use convert_msgpack::{from_msgpack_file, from_msgpack_reader, from_msgpack_slice};
pub use convert_msgpack::{to_msgpack_file, to_msgpack_vec, to_msgpack_writer};
pub use convert_toml::{from_toml_file, from_toml_reader, from_toml_slice, from_toml_str};
pub use convert_toml::{to_toml_file, to_toml_string, to_toml_writer};
pub use error::{Error, ErrorKind};
pub use traits::{FromJson, FromMsgPack, FromToml, ToJson, ToMsgPack, ToToml};

mod convert_json;
mod convert_msgpack;
mod convert_toml;
mod error;
mod traits;

/// A specialized `Result` type for this crate.
pub type Result<T> = ::std::result::Result<T, Error>;