pub enum Value {
Null,
Bool(bool),
Integer(i64),
Float(f64),
String(String),
Array(Vec<Value>),
Table(BTreeMap<String, Value>),
}
Expand description
Represents a configuration value.
Variants§
Null
Null/empty value
Bool(bool)
Boolean value
Integer(i64)
Integer value
Float(f64)
Floating point value
String(String)
String value
Array(Vec<Value>)
Array of values
Table(BTreeMap<String, Value>)
Table (key-value pairs)
Implementations§
Source§impl Value
impl Value
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Check if this value is an integer
Sourcepub fn as_integer(&self) -> Result<i64>
pub fn as_integer(&self) -> Result<i64>
Try to convert this value to an integer
Sourcepub fn as_string(&self) -> Result<&str>
pub fn as_string(&self) -> Result<&str>
Try to convert this value to a string - ZERO-COPY optimized
Sourcepub fn to_string_representation(&self) -> Result<String>
pub fn to_string_representation(&self) -> Result<String>
Convert this value to a string representation (allocating)
Sourcepub fn as_array_mut(&mut self) -> Result<&mut Vec<Value>>
pub fn as_array_mut(&mut self) -> Result<&mut Vec<Value>>
Try to get this value as a mutable array
Sourcepub fn as_table_mut(&mut self) -> Result<&mut BTreeMap<String, Value>>
pub fn as_table_mut(&mut self) -> Result<&mut BTreeMap<String, Value>>
Try to get this value as a mutable table
Sourcepub fn get_mut_nested(&mut self, path: &str) -> Result<&mut Value>
pub fn get_mut_nested(&mut self, path: &str) -> Result<&mut Value>
Get a mutable reference to a value by path (ENTERPRISE ERROR HANDLING)
Sourcepub fn set_nested(&mut self, path: &str, value: Value) -> Result<()>
pub fn set_nested(&mut self, path: &str, value: Value) -> Result<()>
Set a value by path, creating intermediate tables as needed (ZERO-COPY optimized)
Sourcepub fn remove(&mut self, path: &str) -> Result<Option<Value>>
pub fn remove(&mut self, path: &str) -> Result<Option<Value>>
Remove a value by path (ENTERPRISE ERROR HANDLING)
Sourcepub fn keys(&self) -> Result<Vec<&str>>
pub fn keys(&self) -> Result<Vec<&str>>
Get all keys at the current level (for tables only) - ZERO-COPY optimized
Sourcepub fn contains_key(&self, path: &str) -> bool
pub fn contains_key(&self, path: &str) -> bool
Check if a path exists
Trait Implementations§
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
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