#[non_exhaustive]pub enum HoconValue {
Object(IndexMap<String, HoconValue>),
Array(Vec<HoconValue>),
Scalar(ScalarValue),
}Expand description
A resolved HOCON value.
This is the tree that Config wraps. You normally interact
with it through the typed getters on Config, but it is also returned
directly by Config::get and
Config::get_list.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Object(IndexMap<String, HoconValue>)
An ordered map of key-value pairs (HOCON object / JSON object).
Array(Vec<HoconValue>)
An ordered list of values (HOCON array / JSON array).
Scalar(ScalarValue)
A leaf value (string, number, boolean, or null).
Implementations§
Source§impl HoconValue
impl HoconValue
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
The string, if this is a string scalar.
Strict: numbers/booleans/null return None (mirrors serde_json::Value::as_str).
For coercing any scalar to text, use Config::get_string.
Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
This value as i64, if it is a scalar coercible to one.
HOCON-aware coercion matching Config::get_i64:
a quoted "8080" and a bare 8080 both yield Some(8080), and a
whole-number numeric scalar (1.0, 1e3) is truncated to its integer
value. A non-whole number (1.5) yields None.
Sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
This value as f64, if it is a scalar whose raw text parses as one.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
This value as bool, if it is a scalar with a recognised boolean spelling.
Accepts true/yes/on and false/no/off (case-insensitive),
matching the serde boolean coercion.
Sourcepub fn as_object(&self) -> Option<&IndexMap<String, HoconValue>>
pub fn as_object(&self) -> Option<&IndexMap<String, HoconValue>>
The underlying ordered map, if this is an object.
Sourcepub fn as_array(&self) -> Option<&[HoconValue]>
pub fn as_array(&self) -> Option<&[HoconValue]>
The underlying slice, if this is an array.
Structural: a numeric-keyed object is not coerced to an array here
(unlike Config::get_list / serde sequence
deserialization). Use get_as::<Vec<_>> / from_value::<Vec<_>> for that.
Trait Implementations§
Source§impl Clone for HoconValue
impl Clone for HoconValue
Source§fn clone(&self) -> HoconValue
fn clone(&self) -> HoconValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more