hocon/value.rs
1use indexmap::IndexMap;
2
3/// A resolved HOCON value.
4///
5/// This is the tree that [`Config`](crate::Config) wraps. You normally interact
6/// with it through the typed getters on `Config`, but it is also returned
7/// directly by [`Config::get`](crate::Config::get) and
8/// [`Config::get_list`](crate::Config::get_list).
9#[non_exhaustive]
10#[derive(Debug, Clone, PartialEq)]
11pub enum HoconValue {
12 /// An ordered map of key-value pairs (HOCON object / JSON object).
13 Object(IndexMap<String, HoconValue>),
14 /// An ordered list of values (HOCON array / JSON array).
15 Array(Vec<HoconValue>),
16 /// A leaf value (string, number, boolean, or null).
17 Scalar(ScalarValue),
18}
19
20/// A scalar (leaf) value inside a HOCON document.
21#[non_exhaustive]
22#[derive(Debug, Clone, PartialEq)]
23pub enum ScalarValue {
24 /// A string value.
25 String(String),
26 /// A 64-bit signed integer.
27 Int(i64),
28 /// A 64-bit floating-point number.
29 Float(f64),
30 /// A boolean value.
31 Bool(bool),
32 /// An explicit null.
33 Null,
34}