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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use Serialize;
use crate::;
use Serializer;
pub use SerializationError;
/// Serialize a value (using serde) into a [`Value`].
///
/// ## Example
/// ```rust
/// #[derive(serde::Serialize)]
/// struct Config {
/// string: String,
/// age: u32,
/// }
///
/// let config = Config {
/// string: "Hello Eon!".to_string(),
/// age: 42,
/// };
///
/// let value = eon::to_value(&config).unwrap();
///
/// let expected = eon::Value::Map([
/// ("string".to_string(), eon::Value::from("Hello Eon!")),
/// ("age".to_string(), eon::Value::from(42)),
/// ].into_iter().collect());
///
/// assert_eq!(value, expected);
/// ```
/// Serialize a value (using serde) into an Eon string.
///
/// ## Example
/// ```rust
/// #[derive(serde::Serialize)]
/// struct Config {
/// string: String,
/// age: u32,
/// }
///
/// let config = Config {
/// string: "Hello Eon!".to_string(),
/// age: 42,
/// };
///
/// let eon_string = eon::to_string(&config, &eon::FormatOptions::default()).unwrap();
///
/// assert_eq!(eon_string.trim(), r#"
/// string: "Hello Eon!"
/// age: 42
/// "#.trim());
/// ```
/// Parse an Eon value from a string into a type `T` that implements [`serde::de::DeserializeOwned`].
///
/// ## Example
/// ```rust
/// #[derive(serde::Deserialize)]
/// struct Config {
/// string: String,
/// age: u32,
/// }
///
/// let eon_source = r#"
/// string: "Hello Eon!"
/// age: 42
/// "#;
///
/// let config: Config = eon::from_str(eon_source).unwrap();
///
/// assert_eq!(config.string, "Hello Eon!");
/// assert_eq!(config.age, 42);
/// ```