pub enum DataValue {
Null,
String(String),
Bool(bool),
Int(isize),
Float(f64),
List(Vec<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
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 = 8usize
const STATIC_HEAP_SIZE: usize = 8usize
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 PartialEq<&str> for DataValue
impl PartialEq<&str> for DataValue
source§impl PartialEq<DataValue> for &str
impl PartialEq<DataValue> for &str
source§impl PartialEq<DataValue> for f64
impl PartialEq<DataValue> for f64
source§impl PartialEq<DataValue> for isize
impl PartialEq<DataValue> for isize
source§impl PartialEq<DataValue> for str
impl PartialEq<DataValue> for str
source§impl PartialEq<isize> for DataValue
impl PartialEq<isize> for DataValue
source§impl PartialEq for DataValue
impl PartialEq for DataValue
source§impl<'a> TryFrom<DataOperator<'a>> for DataValue
impl<'a> TryFrom<DataOperator<'a>> for DataValue
impl StructuralPartialEq for DataValue
Auto Trait Implementations§
impl RefUnwindSafe for DataValue
impl Send for DataValue
impl Sync for DataValue
impl Unpin 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