pub enum Value<'borrow, 'tape, 'input> {
Tape(Value<'tape, 'input>),
Value(Cow<'borrow, Value<'input>>),
}Expand description
A lazy value, this gets initialized with a tape and as long as only non mutating operations are performed it will stay a tape. If a mutating operation is performed it will upgrade to a borrowed value.
Variants§
Implementations§
Source§impl<'tape, 'input> Value<'_, 'tape, 'input>
impl<'tape, 'input> Value<'_, 'tape, 'input>
Source§impl<'tape, 'input> Value<'_, 'tape, 'input>where
'input: 'tape,
impl<'tape, 'input> Value<'_, 'tape, 'input>where
'input: 'tape,
Sourcepub fn try_get_idx(
&self,
i: usize,
) -> Result<Option<Value<'_, 'tape, 'input>>, TryTypeError>
pub fn try_get_idx( &self, i: usize, ) -> Result<Option<Value<'_, 'tape, 'input>>, TryTypeError>
Tries to get a value based on n index, returns a type error if the
current value isn’t an Array, returns None if the index is out of bounds
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Source§impl<'tape, 'input> Value<'_, 'tape, 'input>
impl<'tape, 'input> Value<'_, 'tape, 'input>
Sourcepub fn try_as_array(&self) -> Result<Array<'_, 'tape, 'input>, TryTypeError>
pub fn try_as_array(&self) -> Result<Array<'_, 'tape, 'input>, TryTypeError>
Tries to represent the value as an array and returns a reference to it
§Errors
if the requested type doesn’t match the actual type
Sourcepub fn try_as_object(&self) -> Result<Object<'_, 'tape, 'input>, TryTypeError>
pub fn try_as_object(&self) -> Result<Object<'_, 'tape, 'input>, TryTypeError>
Tries to represent the value as an object and returns a reference to it
§Errors
if the requested type doesn’t match the actual type
Source§impl<'tape, 'input> Value<'_, 'tape, 'input>
impl<'tape, 'input> Value<'_, 'tape, 'input>
Source§impl<'tape, 'input> Value<'_, 'tape, 'input>where
'input: 'tape,
impl<'tape, 'input> Value<'_, 'tape, 'input>where
'input: 'tape,
Sourcepub fn get_bool<Q>(&self, k: &Q) -> Option<bool>
pub fn get_bool<Q>(&self, k: &Q) -> Option<bool>
Tries to get an element of an object as a bool
Sourcepub fn get_i128<Q>(&self, k: &Q) -> Option<i128>
pub fn get_i128<Q>(&self, k: &Q) -> Option<i128>
Tries to get an element of an object as a i128
Sourcepub fn get_u128<Q>(&self, k: &Q) -> Option<u128>
pub fn get_u128<Q>(&self, k: &Q) -> Option<u128>
Tries to get an element of an object as a u128
Sourcepub fn get_usize<Q>(&self, k: &Q) -> Option<usize>
pub fn get_usize<Q>(&self, k: &Q) -> Option<usize>
Tries to get an element of an object as a usize
Source§impl<'tape, 'input> Value<'_, 'tape, 'input>
impl<'tape, 'input> Value<'_, 'tape, 'input>
Source§impl<'tape, 'input> Value<'_, 'tape, 'input>
impl<'tape, 'input> Value<'_, 'tape, 'input>
Sourcepub fn try_get_array<Q>(
&self,
k: &Q,
) -> Result<Option<Array<'_, 'tape, 'input>>, TryTypeError>
pub fn try_get_array<Q>( &self, k: &Q, ) -> Result<Option<Array<'_, 'tape, 'input>>, TryTypeError>
Tries to get an element of an object as an array, returns an error if it isn’t a array
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_object<Q>(
&self,
k: &Q,
) -> Result<Option<Object<'_, 'tape, 'input>>, TryTypeError>
pub fn try_get_object<Q>( &self, k: &Q, ) -> Result<Option<Object<'_, 'tape, 'input>>, TryTypeError>
Tries to get an element of an object as an object, returns an error if it isn’t an object
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Source§impl Value<'_, '_, '_>
impl Value<'_, '_, '_>
Sourcepub fn try_get_bool<Q>(&self, k: &Q) -> Result<Option<bool>, TryTypeError>
pub fn try_get_bool<Q>(&self, k: &Q) -> Result<Option<bool>, TryTypeError>
Tries to get an element of an object as a bool, returns an error if it isn’t bool
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_i128<Q>(&self, k: &Q) -> Result<Option<i128>, TryTypeError>
pub fn try_get_i128<Q>(&self, k: &Q) -> Result<Option<i128>, TryTypeError>
Tries to get an element of an object as a i128, returns an error if it isn’t i128
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_i64<Q>(&self, k: &Q) -> Result<Option<i64>, TryTypeError>
pub fn try_get_i64<Q>(&self, k: &Q) -> Result<Option<i64>, TryTypeError>
Tries to get an element of an object as a i64, returns an error if it isn’t a i64
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_i32<Q>(&self, k: &Q) -> Result<Option<i32>, TryTypeError>
pub fn try_get_i32<Q>(&self, k: &Q) -> Result<Option<i32>, TryTypeError>
Tries to get an element of an object as a i32, returns an error if it isn’t a i32
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_i16<Q>(&self, k: &Q) -> Result<Option<i16>, TryTypeError>
pub fn try_get_i16<Q>(&self, k: &Q) -> Result<Option<i16>, TryTypeError>
Tries to get an element of an object as a i16, returns an error if it isn’t a i16
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_i8<Q>(&self, k: &Q) -> Result<Option<i8>, TryTypeError>
pub fn try_get_i8<Q>(&self, k: &Q) -> Result<Option<i8>, TryTypeError>
Tries to get an element of an object as a u128, returns an error if it isn’t a u128
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_u128<Q>(&self, k: &Q) -> Result<Option<u128>, TryTypeError>
pub fn try_get_u128<Q>(&self, k: &Q) -> Result<Option<u128>, TryTypeError>
Tries to get an element of an object as a u64, returns an error if it isn’t a u64
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_u64<Q>(&self, k: &Q) -> Result<Option<u64>, TryTypeError>
pub fn try_get_u64<Q>(&self, k: &Q) -> Result<Option<u64>, TryTypeError>
Tries to get an element of an object as a usize, returns an error if it isn’t a usize
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_usize<Q>(&self, k: &Q) -> Result<Option<usize>, TryTypeError>
pub fn try_get_usize<Q>(&self, k: &Q) -> Result<Option<usize>, TryTypeError>
Tries to get an element of an object as a u32, returns an error if it isn’t a u32
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_u32<Q>(&self, k: &Q) -> Result<Option<u32>, TryTypeError>
pub fn try_get_u32<Q>(&self, k: &Q) -> Result<Option<u32>, TryTypeError>
Tries to get an element of an object as a u16, returns an error if it isn’t a u16
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_u16<Q>(&self, k: &Q) -> Result<Option<u16>, TryTypeError>
pub fn try_get_u16<Q>(&self, k: &Q) -> Result<Option<u16>, TryTypeError>
Tries to get an element of an object as a u8, returns an error if it isn’t a u8
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_u8<Q>(&self, k: &Q) -> Result<Option<u8>, TryTypeError>
pub fn try_get_u8<Q>(&self, k: &Q) -> Result<Option<u8>, TryTypeError>
Tries to get an element of an object as a u8, returns an error if it isn’t a u8
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_f64<Q>(&self, k: &Q) -> Result<Option<f64>, TryTypeError>
pub fn try_get_f64<Q>(&self, k: &Q) -> Result<Option<f64>, TryTypeError>
Tries to get an element of an object as a f64, returns an error if it isn’t a f64
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_f32<Q>(&self, k: &Q) -> Result<Option<f32>, TryTypeError>
pub fn try_get_f32<Q>(&self, k: &Q) -> Result<Option<f32>, TryTypeError>
Tries to get an element of an object as a f32, returns an error if it isn’t a f32
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Sourcepub fn try_get_str<Q>(&self, k: &Q) -> Result<Option<&str>, TryTypeError>
pub fn try_get_str<Q>(&self, k: &Q) -> Result<Option<&str>, TryTypeError>
Tries to get an element of an object as a str, returns an error if it isn’t a str
§Errors
if the requested type doesn’t match the actual type or the value is not an object
Source§impl<'tape, 'input> Value<'_, 'tape, 'input>
impl<'tape, 'input> Value<'_, 'tape, 'input>
Sourcepub fn into_value(self) -> Value<'input>
pub fn into_value(self) -> Value<'input>
turns the lazy value into a borrowed value
Sourcepub fn into_owned<'snot>(self) -> Value<'snot, 'tape, 'input>
pub fn into_owned<'snot>(self) -> Value<'snot, 'tape, 'input>
extends the Value COW is owned
Trait Implementations§
Source§impl<'value> From<Cow<'value, str>> for Value<'_, '_, 'value>
Available on non-crate feature beef only.
impl<'value> From<Cow<'value, str>> for Value<'_, '_, 'value>
beef only.Source§impl From<StaticNode> for Value<'_, '_, '_>
impl From<StaticNode> for Value<'_, '_, '_>
Source§fn from(v: StaticNode) -> Self
fn from(v: StaticNode) -> Self
Source§impl<'value, K: Into<Cow<'value, str>>, V: Into<Value<'value>>> FromIterator<(K, V)> for Value<'_, '_, 'value>
impl<'value, K: Into<Cow<'value, str>>, V: Into<Value<'value>>> FromIterator<(K, V)> for Value<'_, '_, 'value>
Source§impl<'value, V: Into<Value<'value>>> FromIterator<V> for Value<'_, '_, 'value>
impl<'value, V: Into<Value<'value>>> FromIterator<V> for Value<'_, '_, 'value>
Source§fn from_iter<I: IntoIterator<Item = V>>(v: I) -> Self
fn from_iter<I: IntoIterator<Item = V>>(v: I) -> Self
impl<'borrow, 'tape, 'input> StructuralPartialEq for Value<'borrow, 'tape, 'input>
Source§impl TypedValue for Value<'_, '_, '_>
impl TypedValue for Value<'_, '_, '_>
Source§fn value_type(&self) -> ValueType
fn value_type(&self) -> ValueType
Source§impl<'input> ValueAsMutArray for Value<'_, '_, 'input>
impl<'input> ValueAsMutArray for Value<'_, '_, 'input>
Source§impl<'input> ValueAsMutObject for Value<'_, '_, 'input>
impl<'input> ValueAsMutObject for Value<'_, '_, 'input>
Source§impl ValueAsScalar for Value<'_, '_, '_>
impl ValueAsScalar for Value<'_, '_, '_>
Source§impl<'value> ValueBuilder<'value> for Value<'static, 'static, 'value>
impl<'value> ValueBuilder<'value> for Value<'static, 'static, 'value>
Source§fn array_with_capacity(capacity: usize) -> Self
fn array_with_capacity(capacity: usize) -> Self
Source§fn object_with_capacity(capacity: usize) -> Self
fn object_with_capacity(capacity: usize) -> Self
Source§impl<'value> ValueIntoString for Value<'_, '_, 'value>
impl<'value> ValueIntoString for Value<'_, '_, 'value>
Source§impl Writable for Value<'_, '_, '_>
impl Writable for Value<'_, '_, '_>
Auto Trait Implementations§
impl<'borrow, 'tape, 'input> Freeze for Value<'borrow, 'tape, 'input>
impl<'borrow, 'tape, 'input> RefUnwindSafe for Value<'borrow, 'tape, 'input>
impl<'borrow, 'tape, 'input> Send for Value<'borrow, 'tape, 'input>
impl<'borrow, 'tape, 'input> Sync for Value<'borrow, 'tape, 'input>
impl<'borrow, 'tape, 'input> Unpin for Value<'borrow, 'tape, 'input>
impl<'borrow, 'tape, 'input> UnsafeUnpin for Value<'borrow, 'tape, 'input>
impl<'borrow, 'tape, 'input> UnwindSafe for Value<'borrow, 'tape, 'input>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> MutableArray for T
impl<T> MutableArray for T
Source§fn pop(&mut self) -> Result<Option<<T as MutableArray>::Target>, AccessError>
fn pop(&mut self) -> Result<Option<<T as MutableArray>::Target>, AccessError>
Pops from this Value as an Array.
Will return an AccessError::NotAnArray if called
on a Value that isn’t an Array - otherwise will
behave the same as Vec::pop
§Errors
Will return Err if self is not an array.
Source§fn push<V>(&mut self, v: V) -> Result<(), AccessError>
fn push<V>(&mut self, v: V) -> Result<(), AccessError>
Value as an Array.
Will return an AccessError::NotAnArray if called
on a Value that isn’t an Array - otherwise will
behave the same as Vec::push Read moreSource§impl<T> MutableObject for T
impl<T> MutableObject for T
Source§type Target = <<T as ValueAsMutObject>::Object as ObjectMut>::Element
type Target = <<T as ValueAsMutObject>::Object as ObjectMut>::Element
Source§type Object = <T as ValueAsMutObject>::Object
type Object = <T as ValueAsMutObject>::Object
Source§fn insert<K, V>(
&mut self,
k: K,
v: V,
) -> Result<Option<<T as MutableObject>::Target>, AccessError>
fn insert<K, V>( &mut self, k: K, v: V, ) -> Result<Option<<T as MutableObject>::Target>, AccessError>
Value as an Object.
Will return an AccessError::NotAnObject if called
on a Value that isn’t an object - otherwise will
behave the same as HashMap::insert Read moreSource§fn remove<Q>(
&mut self,
k: &Q,
) -> Result<Option<<T as MutableObject>::Target>, AccessError>
fn remove<Q>( &mut self, k: &Q, ) -> Result<Option<<T as MutableObject>::Target>, AccessError>
Value as an Object.
Will return an AccessError::NotAnObject if called
on a Value that isn’t an object - otherwise will
behave the same as HashMap::remove Read moreSource§fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut <T as MutableObject>::Target>
fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut <T as MutableObject>::Target>
get but returns a mutable ref insteadSource§fn try_insert<K, V>(&mut self, k: K, v: V) -> Option<Self::Target>
fn try_insert<K, V>(&mut self, k: K, v: V) -> Option<Self::Target>
Value as an Object.
If the Value isn’t an object this opoeration will
return None and have no effect.Source§impl<T, I> MutableValueArrayAccess<I> for T
impl<T, I> MutableValueArrayAccess<I> for T
Source§fn get_idx_mut(
&mut self,
i: I,
) -> Option<&mut <T as MutableValueArrayAccess<I>>::Target>
fn get_idx_mut( &mut self, i: I, ) -> Option<&mut <T as MutableValueArrayAccess<I>>::Target>
Same as get_idx but returns a mutable ref instead