pub enum DataValue {
Null,
String(String),
Bool(bool),
Int(isize),
Float(f64),
List(Vec<DataValue>),
Datetime(DateTime<FixedOffset>),
Map(BTreeMap<String, DataValue>),
}Expand description
This type encapsulates a value and its type.
It is held by AnnotationData alongside a reference to a DataKey, resulting in a key/value pair.
Variants§
Null
No value
String(String)
A string value
Bool(bool)
A boolean value
Int(isize)
A numeric integer value
Float(f64)
A numeric floating-point value
List(Vec<DataValue>)
Value is an unordered set The value is an ordered list
Datetime(DateTime<FixedOffset>)
The value is a date/timestamp
Map(BTreeMap<String, DataValue>)
The value is a map
Implementations§
Source§impl<'a> DataValue
impl<'a> DataValue
Sourcepub fn test(&self, operator: &DataOperator<'a>) -> bool
pub fn test(&self, operator: &DataOperator<'a>) -> bool
This applies a DataOperator to the data value, and returns a boolean if the values passes the constraints posed by the operator.
Note that the DataOperator itself holds the value that is tested against.
Sourcepub fn to_json(&self) -> Result<String, StamError>
pub fn to_json(&self) -> Result<String, StamError>
Writes a datavalue to one STAM JSON string, with appropriate formatting
Sourcepub fn to_json_compact(&self) -> Result<String, StamError>
pub fn to_json_compact(&self) -> Result<String, StamError>
Writes a datavalue to one STAM JSON string, without any indentation
Trait Implementations§
Source§impl DataSize for DataValue
impl DataSize for DataValue
Source§const IS_DYNAMIC: bool = true
const IS_DYNAMIC: bool = true
If
true, the type has a heap size that can vary at runtime, depending on the actual value.Source§const STATIC_HEAP_SIZE: usize = 8
const STATIC_HEAP_SIZE: usize = 8
The amount of space a value of the type always occupies. If
IS_DYNAMIC is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.Source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Estimates the size of heap memory taken up by this value. Read more
Source§impl<'de> Deserialize<'de> for DataValue
impl<'de> Deserialize<'de> for DataValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a> From<&'a DataValue> for DataOperator<'a>
impl<'a> From<&'a DataValue> for DataOperator<'a>
Source§impl From<DateTime<FixedOffset>> for DataValue
impl From<DateTime<FixedOffset>> for DataValue
Source§fn from(item: DateTime<FixedOffset>) -> Self
fn from(item: DateTime<FixedOffset>) -> Self
Converts to this type from the input type.
Source§impl<'a> TryFrom<DataOperator<'a>> for DataValue
impl<'a> TryFrom<DataOperator<'a>> for DataValue
impl StructuralPartialEq for DataValue
Auto Trait Implementations§
impl Freeze for DataValue
impl RefUnwindSafe for DataValue
impl Send for DataValue
impl Sync for DataValue
impl Unpin for DataValue
impl UnsafeUnpin for DataValue
impl UnwindSafe for DataValue
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more