pub struct PeekDynamicValue<'mem, 'facet> { /* private fields */ }Expand description
Lets you read from a dynamic value (implements read-only operations for DynamicValue types)
This is used for types like facet_value::Value that can hold any of:
null, bool, number, string, bytes, array, or object - determined at runtime.
Implementations§
Source§impl<'mem, 'facet> PeekDynamicValue<'mem, 'facet>
impl<'mem, 'facet> PeekDynamicValue<'mem, 'facet>
Sourcepub fn def(&self) -> DynamicValueDef
pub fn def(&self) -> DynamicValueDef
Returns the dynamic value definition
Sourcepub fn kind(&self) -> DynValueKind
pub fn kind(&self) -> DynValueKind
Returns the kind of value stored
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the boolean value if this is a bool, None otherwise
Sourcepub fn as_str(&self) -> Option<&'mem str>
pub fn as_str(&self) -> Option<&'mem str>
Returns the string value if this is a string, None otherwise
Sourcepub fn as_bytes(&self) -> Option<&'mem [u8]>
pub fn as_bytes(&self) -> Option<&'mem [u8]>
Returns the bytes value if this is bytes, None otherwise
Sourcepub fn as_datetime(
&self,
) -> Option<(i32, u8, u8, u8, u8, u8, u32, DynDateTimeKind)>
pub fn as_datetime( &self, ) -> Option<(i32, u8, u8, u8, u8, u8, u32, DynDateTimeKind)>
Returns the datetime components if this is a datetime, None otherwise
Returns (year, month, day, hour, minute, second, nanos, kind).
Sourcepub fn array_len(&self) -> Option<usize>
pub fn array_len(&self) -> Option<usize>
Returns the length of the array if this is an array, None otherwise
Sourcepub fn array_get(&self, index: usize) -> Option<Peek<'mem, 'facet>>
pub fn array_get(&self, index: usize) -> Option<Peek<'mem, 'facet>>
Returns an element from the array by index, None if not an array or index out of bounds
Sourcepub fn object_len(&self) -> Option<usize>
pub fn object_len(&self) -> Option<usize>
Returns the length of the object if this is an object, None otherwise
Sourcepub fn object_get_entry(
&self,
index: usize,
) -> Option<(&'mem str, Peek<'mem, 'facet>)>
pub fn object_get_entry( &self, index: usize, ) -> Option<(&'mem str, Peek<'mem, 'facet>)>
Returns a key-value pair from the object by index, None if not an object or index out of bounds
Sourcepub fn object_get(&self, key: &str) -> Option<Peek<'mem, 'facet>>
pub fn object_get(&self, key: &str) -> Option<Peek<'mem, 'facet>>
Returns a value from the object by key, None if not an object or key not found
Sourcepub fn array_iter(&self) -> Option<PeekDynamicValueArrayIter<'mem, 'facet>>
pub fn array_iter(&self) -> Option<PeekDynamicValueArrayIter<'mem, 'facet>>
Returns an iterator over array elements if this is an array
Sourcepub fn object_iter(&self) -> Option<PeekDynamicValueObjectIter<'mem, 'facet>>
pub fn object_iter(&self) -> Option<PeekDynamicValueObjectIter<'mem, 'facet>>
Returns an iterator over object entries if this is an object
Sourcepub fn structural_hash_inner<H: Hasher>(&self, hasher: &mut H)
pub fn structural_hash_inner<H: Hasher>(&self, hasher: &mut H)
Structurally hash the dynamic value’s contents.
This is called by Peek::structural_hash for dynamic values.
Trait Implementations§
Source§impl<'mem, 'facet> Clone for PeekDynamicValue<'mem, 'facet>
impl<'mem, 'facet> Clone for PeekDynamicValue<'mem, 'facet>
Source§fn clone(&self) -> PeekDynamicValue<'mem, 'facet>
fn clone(&self) -> PeekDynamicValue<'mem, 'facet>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more