PeekDynamicValue

Struct PeekDynamicValue 

Source
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>

Source

pub fn def(&self) -> DynamicValueDef

Returns the dynamic value definition

Source

pub fn peek(&self) -> Peek<'mem, 'facet>

Returns the underlying peek value

Source

pub fn kind(&self) -> DynValueKind

Returns the kind of value stored

Source

pub fn is_null(&self) -> bool

Returns true if the value is null

Source

pub fn as_bool(&self) -> Option<bool>

Returns the boolean value if this is a bool, None otherwise

Source

pub fn as_i64(&self) -> Option<i64>

Returns the i64 value if representable, None otherwise

Source

pub fn as_u64(&self) -> Option<u64>

Returns the u64 value if representable, None otherwise

Source

pub fn as_f64(&self) -> Option<f64>

Returns the f64 value if this is a number, None otherwise

Source

pub fn as_str(&self) -> Option<&'mem str>

Returns the string value if this is a string, None otherwise

Source

pub fn as_bytes(&self) -> Option<&'mem [u8]>

Returns the bytes value if this is bytes, None otherwise

Source

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).

Source

pub fn array_len(&self) -> Option<usize>

Returns the length of the array if this is an array, None otherwise

Source

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

Source

pub fn object_len(&self) -> Option<usize>

Returns the length of the object if this is an object, None otherwise

Source

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

Source

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

Source

pub fn array_iter(&self) -> Option<PeekDynamicValueArrayIter<'mem, 'facet>>

Returns an iterator over array elements if this is an array

Source

pub fn object_iter(&self) -> Option<PeekDynamicValueObjectIter<'mem, 'facet>>

Returns an iterator over object entries if this is an object

Source

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>

Source§

fn clone(&self) -> PeekDynamicValue<'mem, 'facet>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PeekDynamicValue<'_, '_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'mem, 'facet> Copy for PeekDynamicValue<'mem, 'facet>

Auto Trait Implementations§

§

impl<'mem, 'facet> Freeze for PeekDynamicValue<'mem, 'facet>

§

impl<'mem, 'facet> RefUnwindSafe for PeekDynamicValue<'mem, 'facet>

§

impl<'mem, 'facet> !Send for PeekDynamicValue<'mem, 'facet>

§

impl<'mem, 'facet> !Sync for PeekDynamicValue<'mem, 'facet>

§

impl<'mem, 'facet> Unpin for PeekDynamicValue<'mem, 'facet>

§

impl<'mem, 'facet> UnwindSafe for PeekDynamicValue<'mem, 'facet>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.