pub enum OptionValue {
Bool(bool),
Integer(i64),
Float(f64),
String(String),
List(Vec<OptionValue>),
Map(Options),
}Expand description
Dynamically typed loader option or nested option map.
§Examples
use tanzim_source::{OptionValue, OptionValueType};
let value = OptionValue::Integer(3);
assert_eq!(value.type_name(), OptionValueType::Integer);
assert_eq!(value.as_integer(), Some(3));
assert_eq!(value.as_bool(), None);Variants§
Bool(bool)
A boolean value.
Integer(i64)
A 64-bit signed integer.
Float(f64)
A 64-bit floating-point number.
String(String)
A string value.
List(Vec<OptionValue>)
A list of values.
Map(Options)
A nested option map.
Implementations§
Source§impl OptionValue
impl OptionValue
Sourcepub fn new_map() -> Self
pub fn new_map() -> Self
Build an empty OptionValue::Map.
Sourcepub fn new_list() -> Self
pub fn new_list() -> Self
Build an empty OptionValue::List.
Sourcepub fn new_string() -> Self
pub fn new_string() -> Self
Build an empty OptionValue::String.
Sourcepub fn is_bool(&self) -> bool
pub fn is_bool(&self) -> bool
true if this is a OptionValue::Bool.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
The boolean value, or None if this is not a OptionValue::Bool.
Sourcepub fn into_bool(self) -> Option<bool>
pub fn into_bool(self) -> Option<bool>
Convert into the boolean value, or None if this is not a OptionValue::Bool.
Sourcepub fn bool_mut(&mut self) -> Option<&mut bool>
pub fn bool_mut(&mut self) -> Option<&mut bool>
A mutable reference to the boolean value, or None if this is not a OptionValue::Bool.
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
true if this is a OptionValue::Integer.
Sourcepub fn as_integer(&self) -> Option<i64>
pub fn as_integer(&self) -> Option<i64>
The integer value, or None if this is not a OptionValue::Integer.
Sourcepub fn into_integer(self) -> Option<i64>
pub fn into_integer(self) -> Option<i64>
Convert into the integer value, or None if this is not a OptionValue::Integer.
Sourcepub fn integer_mut(&mut self) -> Option<&mut i64>
pub fn integer_mut(&mut self) -> Option<&mut i64>
A mutable reference to the integer value, or None if this is not a OptionValue::Integer.
Sourcepub fn is_float(&self) -> bool
pub fn is_float(&self) -> bool
true if this is a OptionValue::Float.
Sourcepub fn as_float(&self) -> Option<f64>
pub fn as_float(&self) -> Option<f64>
The float value, or None if this is not a OptionValue::Float.
Sourcepub fn into_float(self) -> Option<f64>
pub fn into_float(self) -> Option<f64>
Convert into the float value, or None if this is not a OptionValue::Float.
Sourcepub fn float_mut(&mut self) -> Option<&mut f64>
pub fn float_mut(&mut self) -> Option<&mut f64>
A mutable reference to the float value, or None if this is not a OptionValue::Float.
Sourcepub fn is_string(&self) -> bool
pub fn is_string(&self) -> bool
true if this is a OptionValue::String.
Sourcepub fn as_string(&self) -> Option<&String>
pub fn as_string(&self) -> Option<&String>
The string value, or None if this is not a OptionValue::String.
Sourcepub fn into_string(self) -> Option<String>
pub fn into_string(self) -> Option<String>
Convert into the string value, or None if this is not a OptionValue::String.
Sourcepub fn string_mut(&mut self) -> Option<&mut String>
pub fn string_mut(&mut self) -> Option<&mut String>
A mutable reference to the string value, or None if this is not a OptionValue::String.
Sourcepub fn is_list(&self) -> bool
pub fn is_list(&self) -> bool
true if this is a OptionValue::List.
Sourcepub fn as_list(&self) -> Option<&Vec<OptionValue>>
pub fn as_list(&self) -> Option<&Vec<OptionValue>>
The list value, or None if this is not a OptionValue::List.
Sourcepub fn into_list(self) -> Option<Vec<OptionValue>>
pub fn into_list(self) -> Option<Vec<OptionValue>>
Convert into the list value, or None if this is not a OptionValue::List.
Sourcepub fn list_mut(&mut self) -> Option<&mut Vec<OptionValue>>
pub fn list_mut(&mut self) -> Option<&mut Vec<OptionValue>>
A mutable reference to the list value, or None if this is not a OptionValue::List.
Sourcepub fn is_map(&self) -> bool
pub fn is_map(&self) -> bool
true if this is a OptionValue::Map.
Sourcepub fn as_map(&self) -> Option<&Options>
pub fn as_map(&self) -> Option<&Options>
The map value, or None if this is not a OptionValue::Map.
Sourcepub fn into_map(self) -> Option<Options>
pub fn into_map(self) -> Option<Options>
Convert into the map value, or None if this is not a OptionValue::Map.
Sourcepub fn map_mut(&mut self) -> Option<&mut Options>
pub fn map_mut(&mut self) -> Option<&mut Options>
A mutable reference to the map value, or None if this is not a OptionValue::Map.
Sourcepub fn type_name(&self) -> OptionValueType
pub fn type_name(&self) -> OptionValueType
The OptionValueType kind of this value.
Trait Implementations§
Source§impl Clone for OptionValue
impl Clone for OptionValue
Source§fn clone(&self) -> OptionValue
fn clone(&self) -> OptionValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more