1use anyhow::Error;
8use thiserror::Error as ThisError;
9
10#[macro_use]
11mod macros;
12
13#[cfg(feature = "bincode")]
14#[doc(hidden)]
15pub mod bincode;
16
17#[cfg(feature = "cbor")]
18#[doc(hidden)]
19pub mod cbor;
20
21#[doc(hidden)]
22pub mod json;
23
24#[doc(hidden)]
25#[cfg(feature = "msgpack")]
26pub mod msgpack;
27
28#[doc(hidden)]
29pub mod nothing;
30
31#[cfg(feature = "toml")]
32#[doc(hidden)]
33pub mod toml;
34
35#[cfg(feature = "yaml")]
36#[doc(hidden)]
37pub mod yaml;
38
39#[cfg(feature = "bincode")]
40#[doc(inline)]
41pub use self::bincode::Bincode;
42
43#[cfg(feature = "cbor")]
44#[doc(inline)]
45pub use self::cbor::Cbor;
46
47#[doc(inline)]
48pub use self::json::Json;
49
50#[cfg(feature = "msgpack")]
51#[doc(inline)]
52pub use self::msgpack::MsgPack;
53
54#[doc(inline)]
55pub use self::nothing::Nothing;
56
57#[cfg(feature = "toml")]
58#[doc(inline)]
59pub use self::toml::Toml;
60
61#[cfg(feature = "yaml")]
62#[doc(inline)]
63pub use self::yaml::Yaml;
64
65pub type Text = Result<String, Error>;
70
71pub type Binary = Result<Vec<u8>, Error>;
73
74#[doc(hidden)]
76pub type Format<T> = Result<T, Error>;
77
78#[derive(Debug, ThisError)]
80pub enum FormatError {
81 #[error("received text for a binary format")]
84 ReceivedTextForBinary,
85 #[error("received binary for a text format")]
88 ReceivedBinaryForText,
89 #[error("trying to encode a binary format as Text")]
92 CantEncodeBinaryAsText,
93}