pub enum ConfigValue {
Null,
Bool(bool),
Integer(i64),
Float(f64),
String(String),
Array(Vec<ConfigValue>),
Object(HashMap<String, ConfigValue>),
Duration(Duration),
}Expand description
A dynamic configuration value that can hold various types
Variants§
Null
Null/None value
Bool(bool)
Boolean value
Integer(i64)
Integer value
Float(f64)
Floating point value
String(String)
String value
Array(Vec<ConfigValue>)
Array of values
Object(HashMap<String, ConfigValue>)
Object/Map of values
Duration(Duration)
Duration value (serialized as seconds)
Implementations§
Source§impl ConfigValue
impl ConfigValue
Sourcepub fn as_integer(&self) -> Result<i64>
pub fn as_integer(&self) -> Result<i64>
Convert to integer, returning error if conversion fails
Sourcepub fn as_array(&self) -> Result<&Vec<ConfigValue>>
pub fn as_array(&self) -> Result<&Vec<ConfigValue>>
Convert to array, returning error if conversion fails
Sourcepub fn as_object(&self) -> Result<&HashMap<String, ConfigValue>>
pub fn as_object(&self) -> Result<&HashMap<String, ConfigValue>>
Convert to object/map, returning error if conversion fails
Sourcepub fn as_duration(&self) -> Result<Duration>
pub fn as_duration(&self) -> Result<Duration>
Convert to duration, returning error if conversion fails
Sourcepub fn get_path(&self, path: &str) -> Option<&ConfigValue>
pub fn get_path(&self, path: &str) -> Option<&ConfigValue>
Get a nested value by dot-separated path
Sourcepub fn set_path(&mut self, path: &str, value: ConfigValue) -> Result<()>
pub fn set_path(&mut self, path: &str, value: ConfigValue) -> Result<()>
Set a nested value by dot-separated path
Sourcepub fn merge(&mut self, other: ConfigValue)
pub fn merge(&mut self, other: ConfigValue)
Merge another ConfigValue into this one
Trait Implementations§
Source§impl Clone for ConfigValue
impl Clone for ConfigValue
Source§fn clone(&self) -> ConfigValue
fn clone(&self) -> ConfigValue
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConfigValue
impl Debug for ConfigValue
Source§impl<'de> Deserialize<'de> for ConfigValue
impl<'de> Deserialize<'de> for ConfigValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&str> for ConfigValue
impl From<&str> for ConfigValue
Source§impl From<Duration> for ConfigValue
impl From<Duration> for ConfigValue
Source§impl From<HashMap<String, ConfigValue>> for ConfigValue
impl From<HashMap<String, ConfigValue>> for ConfigValue
Source§impl From<String> for ConfigValue
impl From<String> for ConfigValue
Source§impl From<Value> for ConfigValue
impl From<Value> for ConfigValue
Source§impl From<Vec<ConfigValue>> for ConfigValue
impl From<Vec<ConfigValue>> for ConfigValue
Source§fn from(value: Vec<ConfigValue>) -> Self
fn from(value: Vec<ConfigValue>) -> Self
Converts to this type from the input type.
Source§impl From<bool> for ConfigValue
impl From<bool> for ConfigValue
Source§impl From<f64> for ConfigValue
impl From<f64> for ConfigValue
Source§impl From<i32> for ConfigValue
impl From<i32> for ConfigValue
Source§impl From<i64> for ConfigValue
impl From<i64> for ConfigValue
Source§impl From<u32> for ConfigValue
impl From<u32> for ConfigValue
Source§impl PartialEq for ConfigValue
impl PartialEq for ConfigValue
Source§impl Serialize for ConfigValue
impl Serialize for ConfigValue
impl StructuralPartialEq for ConfigValue
Auto Trait Implementations§
impl Freeze for ConfigValue
impl RefUnwindSafe for ConfigValue
impl Send for ConfigValue
impl Sync for ConfigValue
impl Unpin for ConfigValue
impl UnwindSafe for ConfigValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more