pub enum Value {
Null,
Bool(bool),
Int(i64),
Float(f64),
String(String),
Sequence(Vec<Value>),
Mapping(IndexMap<Value, Value>),
}Expand description
A YAML value with all possible types
Variants§
Null
Null value
Bool(bool)
Boolean value
Int(i64)
Integer value
Float(f64)
Floating point value
String(String)
String value
Sequence(Vec<Value>)
Sequence (array/list) value
Mapping(IndexMap<Value, Value>)
Mapping (dictionary/object) value
Implementations§
Source§impl Value
impl Value
Sourcepub const fn sequence_with(values: Vec<Self>) -> Self
pub const fn sequence_with(values: Vec<Self>) -> Self
Create a sequence with values
Sourcepub fn mapping_with(pairs: Vec<(Self, Self)>) -> Self
pub fn mapping_with(pairs: Vec<(Self, Self)>) -> Self
Create a mapping with key-value pairs
Sourcepub const fn is_sequence(&self) -> bool
pub const fn is_sequence(&self) -> bool
Check if this value is a sequence
Sourcepub const fn is_mapping(&self) -> bool
pub const fn is_mapping(&self) -> bool
Check if this value is a mapping
Sourcepub const fn as_sequence(&self) -> Option<&Vec<Self>>
pub const fn as_sequence(&self) -> Option<&Vec<Self>>
Get this value as a sequence reference, if possible
Sourcepub const fn as_sequence_mut(&mut self) -> Option<&mut Vec<Self>>
pub const fn as_sequence_mut(&mut self) -> Option<&mut Vec<Self>>
Get this value as a mutable sequence reference, if possible
Sourcepub const fn as_mapping(&self) -> Option<&IndexMap<Self, Self>>
pub const fn as_mapping(&self) -> Option<&IndexMap<Self, Self>>
Get this value as a mapping reference, if possible
Sourcepub const fn as_mapping_mut(&mut self) -> Option<&mut IndexMap<Self, Self>>
pub const fn as_mapping_mut(&mut self) -> Option<&mut IndexMap<Self, Self>>
Get this value as a mutable mapping reference, if possible
Sourcepub fn get_str(&self, key: &str) -> Option<&Self>
pub fn get_str(&self, key: &str) -> Option<&Self>
Convenience method to get a value by string key
Trait Implementations§
Source§impl From<BorrowedValue<'_>> for Value
impl From<BorrowedValue<'_>> for Value
Source§fn from(value: BorrowedValue<'_>) -> Self
fn from(value: BorrowedValue<'_>) -> Self
Converts to this type from the input type.
Source§impl<'a> From<Value> for BorrowedValue<'a>
impl<'a> From<Value> for BorrowedValue<'a>
Source§impl From<Value> for CommentedValue
impl From<Value> for CommentedValue
impl Eq 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.