pub enum Value {
Null,
Bool(bool),
Number(f64),
Str(String),
Date(BaseDate),
Duration(i64),
List(Vec<Value>),
Object(BTreeMap<String, Value>),
Link(BaseLink),
}Expand description
A runtime value in the Bases expression language.
Variants§
Null
Bool(bool)
Number(f64)
Str(String)
Date(BaseDate)
Duration(i64)
A duration in milliseconds (from duration(...) or a date subtraction).
List(Vec<Value>)
Object(BTreeMap<String, Value>)
Link(BaseLink)
Implementations§
Source§impl Value
impl Value
Sourcepub fn is_truthy(&self) -> bool
pub fn is_truthy(&self) -> bool
Obsidian truthiness: null / false / 0 / empty string / empty list / empty
object are falsey; everything else is truthy. Drives filters and if(...).
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the value is “empty” for isEmpty() / the Filled/Empty summaries:
null, empty string, empty list, or empty object.
Sourcepub fn as_number(&self) -> Option<f64>
pub fn as_number(&self) -> Option<f64>
Best-effort numeric coercion (for arithmetic and number(...)). Booleans →
0/1, numeric strings parse, durations → their millisecond count; otherwise
None.
Sourcepub fn as_str_coerced(&self) -> String
pub fn as_str_coerced(&self) -> String
Coerce to a string the way an expression’s + with a string operand would.
Source§impl Value
impl Value
Sourcepub fn loose_eq(&self, other: &Value) -> bool
pub fn loose_eq(&self, other: &Value) -> bool
Structural equality used by ==/!= and .contains(...). Numbers compare
numerically (incl. across numeric strings), links compare by target,
dates by instant; mismatched types are unequal (except numeric coercion).
Sourcepub fn loose_cmp(&self, other: &Value) -> Ordering
pub fn loose_cmp(&self, other: &Value) -> Ordering
Ordering for </>/sorting. Numbers and dates order naturally; strings
lexicographically (case-insensitive, like Obsidian’s column sort); other
combinations fall back to a stable type-name ordering so a sort never
panics on mixed columns. Null sorts last.