pub enum Value {
Null,
Bool(bool),
Int(i64),
Float(f64),
String(String),
Sequence(Vec<Value>),
Mapping(Mapping),
}Expand description
A dynamic metadata value. Integers and floats are kept distinct, and mappings preserve key order (frontmatter is order-significant to humans).
Variants§
Null
Null (~, null), and the Default.
Bool(bool)
Boolean.
Int(i64)
Integer.
Float(f64)
Float.
String(String)
String.
Sequence(Vec<Value>)
Sequence (- item).
Mapping(Mapping)
Mapping (key: value), key order preserved.
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
The string, if this is a Value::String.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
The boolean, if this is a Value::Bool.
Sourcepub fn as_sequence(&self) -> Option<&[Value]>
pub fn as_sequence(&self) -> Option<&[Value]>
The sequence, if this is a Value::Sequence.
Sourcepub fn as_mapping(&self) -> Option<&Mapping>
pub fn as_mapping(&self) -> Option<&Mapping>
The mapping, if this is a Value::Mapping.
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
true if this is Value::Null.
Sourcepub fn get_path(&self, path: &str) -> Option<&Value>
pub fn get_path(&self, path: &str) -> Option<&Value>
Look up a field path — title, generated.how for a key inside a
mapping, sources[2].resource for a key inside one item of a list —
and return the first value it reaches. This is how a fields
declaration names what it governs (see crate::field); a dot is
always a separator, as it is for prov get. A path with a [] step
reaches every item, and this returns the first — a caller that wants
them all walks field::values_at. None
when the path lands on nothing.
Sourcepub fn link_strings(&self) -> Vec<String>
pub fn link_strings(&self) -> Vec<String>
Interpret this value as a list of link strings: a bare string yields one element, a sequence yields its string-shaped elements, anything else yields nothing. This is how a relation field (single or multi) is read.