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 dotted field path — title, or generated.how for a key
inside a mapping — each segment a mapping key. This is how a fields
declaration names what it governs, so a controlled vocabulary can
reach a key one level down (the act in a generated mapping) as it
reaches a top-level one; a dot is always a separator, as it is for
prov get. None when any segment is missing or the value on the way
is not a mapping.
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.