pub enum Value {
Bool(bool),
Int(isize),
Float(f64),
String(String),
List(Vec<LocatedValue>),
Map(Map),
Null,
}Expand description
Dynamically typed configuration value.
The tree shape produced by parsing configuration input: booleans, integers, floats, strings,
lists, maps, and null. Use the is_*/as_*/into_* family of methods to inspect or extract
a specific variant without a match.
use tanzim_value::Value;
let value: Value = 8080isize.into();
assert!(value.is_int());
assert_eq!(value.as_int(), Some(8080));
let value: Value = "localhost".into();
assert_eq!(value.as_string().map(String::as_str), Some("localhost"));Variants§
Bool(bool)
A boolean value.
Int(isize)
A signed integer value.
Float(f64)
A floating-point value.
String(String)
A string value.
List(Vec<LocatedValue>)
A list of located values.
Map(Map)
A map of keys to located values.
Null
The absence of a value.
Implementations§
Source§impl Value
impl Value
Sourcepub fn new_map() -> Value
pub fn new_map() -> Value
Create an empty Value::Map.
Sourcepub fn new_list() -> Value
pub fn new_list() -> Value
Create an empty Value::List.
Sourcepub fn new_string() -> Value
pub fn new_string() -> Value
Create an empty Value::String.
Sourcepub fn is_bool(&self) -> bool
pub fn is_bool(&self) -> bool
true if this is a Value::Bool.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
The boolean, if this is a Value::Bool.
Sourcepub fn into_bool(self) -> Option<bool>
pub fn into_bool(self) -> Option<bool>
Consume and return the boolean, if this is a Value::Bool.
Sourcepub fn bool_mut(&mut self) -> Option<&mut bool>
pub fn bool_mut(&mut self) -> Option<&mut bool>
Mutable access to the boolean, if this is a Value::Bool.
Sourcepub fn is_int(&self) -> bool
pub fn is_int(&self) -> bool
true if this is a Value::Int.
Sourcepub fn as_int(&self) -> Option<isize>
pub fn as_int(&self) -> Option<isize>
The integer, if this is a Value::Int.
Sourcepub fn into_int(self) -> Option<isize>
pub fn into_int(self) -> Option<isize>
Consume and return the integer, if this is a Value::Int.
Sourcepub fn int_mut(&mut self) -> Option<&mut isize>
pub fn int_mut(&mut self) -> Option<&mut isize>
Mutable access to the integer, if this is a Value::Int.
Sourcepub fn is_float(&self) -> bool
pub fn is_float(&self) -> bool
true if this is a Value::Float.
Sourcepub fn as_float(&self) -> Option<f64>
pub fn as_float(&self) -> Option<f64>
The float, if this is a Value::Float.
Sourcepub fn into_float(self) -> Option<f64>
pub fn into_float(self) -> Option<f64>
Consume and return the float, if this is a Value::Float.
Sourcepub fn float_mut(&mut self) -> Option<&mut f64>
pub fn float_mut(&mut self) -> Option<&mut f64>
Mutable access to the float, if this is a Value::Float.
Sourcepub fn is_string(&self) -> bool
pub fn is_string(&self) -> bool
true if this is a Value::String.
Sourcepub fn as_string(&self) -> Option<&String>
pub fn as_string(&self) -> Option<&String>
The string, if this is a Value::String.
Sourcepub fn into_string(self) -> Option<String>
pub fn into_string(self) -> Option<String>
Consume and return the string, if this is a Value::String.
Sourcepub fn string_mut(&mut self) -> Option<&mut String>
pub fn string_mut(&mut self) -> Option<&mut String>
Mutable access to the string, if this is a Value::String.
Sourcepub fn is_list(&self) -> bool
pub fn is_list(&self) -> bool
true if this is a Value::List.
Sourcepub fn as_list(&self) -> Option<&Vec<LocatedValue>>
pub fn as_list(&self) -> Option<&Vec<LocatedValue>>
The list, if this is a Value::List.
Sourcepub fn into_list(self) -> Option<Vec<LocatedValue>>
pub fn into_list(self) -> Option<Vec<LocatedValue>>
Consume and return the list, if this is a Value::List.
Sourcepub fn list_mut(&mut self) -> Option<&mut Vec<LocatedValue>>
pub fn list_mut(&mut self) -> Option<&mut Vec<LocatedValue>>
Mutable access to the list, if this is a Value::List.
Sourcepub fn is_map(&self) -> bool
pub fn is_map(&self) -> bool
true if this is a Value::Map.
Sourcepub fn as_map(&self) -> Option<&Map>
pub fn as_map(&self) -> Option<&Map>
The map, if this is a Value::Map.
Sourcepub fn into_map(self) -> Option<Map>
pub fn into_map(self) -> Option<Map>
Consume and return the map, if this is a Value::Map.
Sourcepub fn map_mut(&mut self) -> Option<&mut Map>
pub fn map_mut(&mut self) -> Option<&mut Map>
Mutable access to the map, if this is a Value::Map.
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
true if this is a Value::Null.