#[non_exhaustive]pub enum Value {
Null,
Bool(bool),
Number(f64),
Text(String),
Date(DateTime),
}Expand description
A value: what fields hold and expressions compute.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Null
No value (a missing field, a JSON null).
Bool(bool)
True or false.
Number(f64)
A number.
Text(String)
Text.
Date(DateTime)
A date and time.
Implementations§
Source§impl Value
impl Value
Sourcepub fn from_json(json: &Value) -> Value
pub fn from_json(json: &Value) -> Value
Converts a JSON scalar; arrays and objects become Null (they are
collections, reached with [Items][].Sum(...)).
Sourcepub fn as_number(&self) -> Option<f64>
pub fn as_number(&self) -> Option<f64>
The value as a number: numbers, booleans (1/0) and numeric text.
Sourcepub fn is_true(&self) -> bool
pub fn is_true(&self) -> bool
Truthiness for conditions: true, non-zero numbers and non-empty text.
Sourcepub fn compare(&self, other: &Value) -> Ordering
pub fn compare(&self, other: &Value) -> Ordering
Orders values for sorting and comparisons: nulls first, then by kind; numbers numerically, text case-insensitively, dates chronologically.
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 UnsafeUnpin 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