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<'borrow, 'tape, 'input> Value<'borrow, 'tape, 'input>
impl<'borrow, 'tape, 'input> Value<'borrow, 'tape, 'input>
Source§impl<'borrow, 'tape, 'input> Value<'borrow, 'tape, 'input>where
'input: 'tape,
impl<'borrow, 'tape, 'input> Value<'borrow, '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<'borrow, 'tape, 'input> Value<'borrow, 'tape, 'input>
impl<'borrow, 'tape, 'input> Value<'borrow, '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<'borrow, 'tape, 'input> Value<'borrow, 'tape, 'input>
impl<'borrow, 'tape, 'input> Value<'borrow, 'tape, 'input>
Source§impl<'borrow, 'tape, 'input> Value<'borrow, 'tape, 'input>where
'input: 'tape,
impl<'borrow, 'tape, 'input> Value<'borrow, '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<'borrow, 'tape, 'input> Value<'borrow, 'tape, 'input>
impl<'borrow, 'tape, 'input> Value<'borrow, 'tape, 'input>
Source§impl<'borrow, 'tape, 'input> Value<'borrow, 'tape, 'input>
impl<'borrow, 'tape, 'input> Value<'borrow, '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<'borrow, 'tape, 'input> Value<'borrow, 'tape, 'input>
impl<'borrow, 'tape, 'input> Value<'borrow, 'tape, 'input>
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<'borrow, 'tape, 'input> Value<'borrow, 'tape, 'input>
impl<'borrow, 'tape, 'input> Value<'borrow, '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