Struct sonic_rs::LazyValue

source ·
pub struct LazyValue<'de> { /* private fields */ }
Expand description

LazyValue is a raw value from json text. Mainly used for get few values from json fastly. LazyValue is only generated when using get for Iterator.

Implementations§

source§

impl<'de> LazyValue<'de>

source

pub fn deserialize<T: Deserialize<'de>>(&'de self) -> Result<T>

source

pub fn as_raw_slice(&self) -> &[u8]

export the raw json text as slice

source

pub fn as_raw_str(&self) -> &str

export the raw json text as str

source

pub fn as_raw_bytes(&self) -> Bytes

export the raw json text as bytes Note: if the input json is not bytes or faststr, there will be a copy.

source

pub fn as_raw_faststr(&self) -> FastStr

export the raw json text as faststr Note: if the input json is not bytes or faststr, there will be a copy.

source

pub fn get_index(&'de self, index: usize) -> Option<Self>

get with index from lazyvalue

source

pub fn get_key(&'de self, key: &str) -> Option<Self>

get with key from lazyvalue

source

pub fn into_cow_str(self) -> Result<Cow<'de, str>>

Trait Implementations§

source§

impl<'de> Debug for LazyValue<'de>

source§

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

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

impl<'de> JsonValue for LazyValue<'de>

§

type ValueType<'dom> = LazyValue<'dom> where Self: 'dom

source§

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

Returns the bool if the JsonValue is a boolean.
source§

fn as_number(&self) -> Option<Number>

Returns the Number value of the JsonValue if it is a Number.
source§

fn as_str(&self) -> Option<&str>

Returns the str if the JsonValue is a string.
source§

fn get_type(&self) -> JsonType

get the type of the JsonValue.
source§

fn get<I: Index>(&self, index: I) -> Option<Self::ValueType<'_>>

Returns the value from index if the JsonValue is an array or object The index may be usize or &str. The usize is for array, the &str is for object.
source§

fn pointer(&self, path: &JsonPointer<'_>) -> Option<Self::ValueType<'_>>

Returns the value from pointer path if the JsonValue is an array or object
source§

fn is_boolean(&self) -> bool

Returns true if the JsonValue is a bool.
source§

fn is_true(&self) -> bool

Returns true if the JsonValue is true.
source§

fn is_false(&self) -> bool

Returns true if the JsonValue is false.
source§

fn is_null(&self) -> bool

Returns true if the JsonValue is null.
source§

fn is_number(&self) -> bool

Returns true if the JsonValue is a number.
source§

fn is_str(&self) -> bool

Returns true if the JsonValue is a string.
source§

fn is_array(&self) -> bool

Returns true if the JsonValue is an array.
source§

fn is_object(&self) -> bool

Returns true if the JsonValue is an object.
source§

fn is_f64(&self) -> bool

Returns true if the JsonValue is a f64.
source§

fn is_i64(&self) -> bool

Returns true if the JsonValue is an i64.
source§

fn is_u64(&self) -> bool

Returns true if the JsonValue is a u64.
source§

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

Returns the i64 value of the JsonValue if it is a i64.
source§

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

Returns the u64 value of the JsonValue if it is a u64.
source§

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

Returns the f64 value of the JsonValue if it is a f64.

Auto Trait Implementations§

§

impl<'de> !RefUnwindSafe for LazyValue<'de>

§

impl<'de> Send for LazyValue<'de>

§

impl<'de> !Sync for LazyValue<'de>

§

impl<'de> Unpin for LazyValue<'de>

§

impl<'de> UnwindSafe for LazyValue<'de>

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, U> Cast<U> for T
where U: FromCast<T>,

source§

fn cast(self) -> U

Numeric cast from self to T.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromCast<T> for T

source§

fn from_cast(t: T) -> T

Numeric cast from T to Self.
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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.