pub enum ConfigValue {
String(String),
Integer(i64),
Float(f64),
Boolean(bool),
Array(Vec<ConfigValue>),
Object(HashMap<String, ConfigValue>),
Null,
}Expand description
Represents a configuration value that can be of various types.
Variants§
String(String)
String value
Integer(i64)
Integer value
Float(f64)
Floating point value
Boolean(bool)
Boolean value
Array(Vec<ConfigValue>)
Array of values
Object(HashMap<String, ConfigValue>)
Object/map of key-value pairs
Null
Null value
Implementations§
Source§impl ConfigValue
impl ConfigValue
Sourcepub fn as_array(&self) -> Option<&Vec<ConfigValue>>
pub fn as_array(&self) -> Option<&Vec<ConfigValue>>
Returns the value as an array reference if it’s an array.
Sourcepub fn as_object(&self) -> Option<&HashMap<String, ConfigValue>>
pub fn as_object(&self) -> Option<&HashMap<String, ConfigValue>>
Returns the value as an object reference if it’s an object.
Sourcepub fn coerce_to_string(&self) -> String
pub fn coerce_to_string(&self) -> String
Coerces the value to a string representation. This method provides intelligent conversion from any ConfigValue type to String.
Sourcepub fn coerce_to_bool(&self) -> Option<bool>
pub fn coerce_to_bool(&self) -> Option<bool>
Coerces the value to a boolean representation. This method provides intelligent conversion from various ConfigValue types to bool. Returns None if the value cannot be meaningfully converted to a boolean.
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<HashMap<String, ConfigValue>> for ConfigValue
impl From<HashMap<String, ConfigValue>> for ConfigValue
Source§impl From<Option<ConfigValue>> for ConfigValue
impl From<Option<ConfigValue>> for ConfigValue
Source§fn from(opt: Option<ConfigValue>) -> Self
fn from(opt: Option<ConfigValue>) -> Self
Converts to this type from the input type.
Source§impl From<String> for ConfigValue
impl From<String> for ConfigValue
Source§impl From<Vec<ConfigValue>> for ConfigValue
impl From<Vec<ConfigValue>> for ConfigValue
Source§fn from(arr: Vec<ConfigValue>) -> Self
fn from(arr: 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<f32> for ConfigValue
impl From<f32> 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
Source§impl TryFrom<ConfigValue> for HashMap<String, ConfigValue>
impl TryFrom<ConfigValue> for HashMap<String, ConfigValue>
Source§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
Source§impl TryFrom<ConfigValue> for String
impl TryFrom<ConfigValue> for String
Source§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
Source§impl TryFrom<ConfigValue> for Vec<ConfigValue>
impl TryFrom<ConfigValue> for Vec<ConfigValue>
Source§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
Source§impl TryFrom<ConfigValue> for bool
impl TryFrom<ConfigValue> for bool
Source§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
Source§impl TryFrom<ConfigValue> for f64
impl TryFrom<ConfigValue> for f64
Source§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
Source§impl TryFrom<ConfigValue> for i64
impl TryFrom<ConfigValue> for i64
Source§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
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