Enum jsonbb::ValueRef

source ·
pub enum ValueRef<'a> {
    Null,
    String(&'a str),
    Number(NumberRef<'a>),
    Bool(bool),
    Array(ArrayRef<'a>),
    Object(ObjectRef<'a>),
}
Expand description

A reference to a JSON value.

Variants§

§

Null

Represents a JSON null value.

§

String(&'a str)

Represents a JSON string.

§

Number(NumberRef<'a>)

Represents a JSON number.

§

Bool(bool)

Represents a JSON boolean.

§

Array(ArrayRef<'a>)

Represents a JSON array.

§

Object(ObjectRef<'a>)

Represents a JSON object.

Implementations§

source§

impl<'a> ValueRef<'a>

source

pub fn from_bytes(bytes: &[u8]) -> ValueRef<'_>

Creates a ValueRef from a byte slice.

source

pub fn is_null(self) -> bool

Returns true if the value is a null. Returns false otherwise.

source

pub fn is_boolean(self) -> bool

Returns true if the value is a boolean. Returns false otherwise.

source

pub fn is_number(self) -> bool

Returns true if the value is a number. Returns false otherwise.

source

pub fn is_u64(self) -> bool

Returns true if the value is an integer between zero and u64::MAX.

source

pub fn is_i64(self) -> bool

Returns true if the value is an integer between i64::MIN and i64::MAX.

source

pub fn is_f64(self) -> bool

Returns true if the value is a number that can be represented by f64.

source

pub fn is_string(self) -> bool

Returns true if the value is a string. Returns false otherwise.

source

pub fn is_array(self) -> bool

Returns true if the value is an array. Returns false otherwise.

source

pub fn is_object(self) -> bool

Returns true if the value is an object. Returns false otherwise.

source

pub fn as_null(self) -> Option<()>

If the value is null, returns (). Returns None otherwise.

source

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

If the value is a boolean, returns the associated bool. Returns None otherwise.

source

pub fn as_number(self) -> Option<NumberRef<'a>>

If the value is a number, returns the associated number. Returns None otherwise.

source

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

If the value is an integer, returns the associated u64. Returns None otherwise.

source

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

If the value is an integer, returns the associated i64. Returns None otherwise.

source

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

If the value is a float, returns the associated f64. Returns None otherwise.

source

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

If the value is a string, returns the associated str. Returns None otherwise.

source

pub fn as_array(self) -> Option<ArrayRef<'a>>

If the value is an array, returns the associated array. Returns None otherwise.

source

pub fn as_object(self) -> Option<ObjectRef<'a>>

If the value is an object, returns the associated map. Returns None otherwise.

source

pub fn to_owned(self) -> Value

Creates owned Value from ValueRef.

source

pub fn capacity(self) -> usize

Returns the capacity to store this value, in bytes.

source

pub fn get(self, index: impl Index) -> Option<ValueRef<'a>>

Index into a JSON array or object. A string index can be used to access a value in an object, and a usize index can be used to access an element of an array.

source

pub fn pointer(self, pointer: &str) -> Option<Self>

Looks up a value by a JSON Pointer.

Trait Implementations§

source§

impl<'a> Clone for ValueRef<'a>

source§

fn clone(&self) -> ValueRef<'a>

Returns a copy 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 ValueRef<'_>

source§

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

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

impl Display for ValueRef<'_>

Display a JSON value as a string.

source§

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

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

impl From<ValueRef<'_>> for Value

source§

fn from(v: ValueRef<'_>) -> Self

Converts to this type from the input type.
source§

impl From<ValueRef<'_>> for Value

Build a serde_json::Value from a jsonbb node.

source§

fn from(value: ValueRef<'_>) -> Self

Converts to this type from the input type.
source§

impl<'a> Hash for ValueRef<'a>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a> Ord for ValueRef<'a>

source§

fn cmp(&self, other: &ValueRef<'a>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<&str> for ValueRef<'_>

source§

fn eq(&self, other: &&str) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<String> for ValueRef<'_>

source§

fn eq(&self, other: &String) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<ValueRef<'_>> for &str

source§

fn eq(&self, other: &ValueRef<'_>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<ValueRef<'_>> for String

source§

fn eq(&self, other: &ValueRef<'_>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<ValueRef<'_>> for str

source§

fn eq(&self, other: &ValueRef<'_>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<bool> for ValueRef<'_>

source§

fn eq(&self, other: &bool) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<f32> for ValueRef<'_>

source§

fn eq(&self, other: &f32) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<f64> for ValueRef<'_>

source§

fn eq(&self, other: &f64) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<i16> for ValueRef<'_>

source§

fn eq(&self, other: &i16) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<i32> for ValueRef<'_>

source§

fn eq(&self, other: &i32) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<i64> for ValueRef<'_>

source§

fn eq(&self, other: &i64) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<i8> for ValueRef<'_>

source§

fn eq(&self, other: &i8) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<isize> for ValueRef<'_>

source§

fn eq(&self, other: &isize) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<str> for ValueRef<'_>

source§

fn eq(&self, other: &str) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<u16> for ValueRef<'_>

source§

fn eq(&self, other: &u16) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<u32> for ValueRef<'_>

source§

fn eq(&self, other: &u32) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<u64> for ValueRef<'_>

source§

fn eq(&self, other: &u64) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<u8> for ValueRef<'_>

source§

fn eq(&self, other: &u8) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<usize> for ValueRef<'_>

source§

fn eq(&self, other: &usize) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> PartialEq for ValueRef<'a>

source§

fn eq(&self, other: &ValueRef<'a>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> PartialOrd for ValueRef<'a>

source§

fn partial_cmp(&self, other: &ValueRef<'a>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for ValueRef<'_>

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<'a> Copy for ValueRef<'a>

source§

impl<'a> Eq for ValueRef<'a>

source§

impl<'a> StructuralPartialEq for ValueRef<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ValueRef<'a>

§

impl<'a> RefUnwindSafe for ValueRef<'a>

§

impl<'a> Send for ValueRef<'a>

§

impl<'a> Sync for ValueRef<'a>

§

impl<'a> Unpin for ValueRef<'a>

§

impl<'a> UnwindSafe for ValueRef<'a>

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.