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>
impl<'a> ValueRef<'a>
sourcepub fn from_bytes(bytes: &[u8]) -> ValueRef<'_>
pub fn from_bytes(bytes: &[u8]) -> ValueRef<'_>
Creates a ValueRef
from a byte slice.
sourcepub fn is_boolean(self) -> bool
pub fn is_boolean(self) -> bool
Returns true if the value is a boolean. Returns false otherwise.
sourcepub fn is_i64(self) -> bool
pub fn is_i64(self) -> bool
Returns true if the value is an integer between i64::MIN
and i64::MAX
.
sourcepub fn is_f64(self) -> bool
pub fn is_f64(self) -> bool
Returns true if the value is a number that can be represented by f64.
sourcepub fn is_object(self) -> bool
pub fn is_object(self) -> bool
Returns true if the value is an object. Returns false otherwise.
sourcepub fn as_bool(self) -> Option<bool>
pub fn as_bool(self) -> Option<bool>
If the value is a boolean, returns the associated bool. Returns None
otherwise.
sourcepub fn as_number(self) -> Option<NumberRef<'a>>
pub fn as_number(self) -> Option<NumberRef<'a>>
If the value is a number, returns the associated number. Returns None
otherwise.
sourcepub fn as_u64(self) -> Option<u64>
pub fn as_u64(self) -> Option<u64>
If the value is an integer, returns the associated u64. Returns None
otherwise.
sourcepub fn as_i64(self) -> Option<i64>
pub fn as_i64(self) -> Option<i64>
If the value is an integer, returns the associated i64. Returns None
otherwise.
sourcepub fn as_f64(self) -> Option<f64>
pub fn as_f64(self) -> Option<f64>
If the value is a float, returns the associated f64. Returns None
otherwise.
sourcepub fn as_str(self) -> Option<&'a str>
pub fn as_str(self) -> Option<&'a str>
If the value is a string, returns the associated str. Returns None
otherwise.
sourcepub fn as_array(self) -> Option<ArrayRef<'a>>
pub fn as_array(self) -> Option<ArrayRef<'a>>
If the value is an array, returns the associated array. Returns None
otherwise.
sourcepub fn as_object(self) -> Option<ObjectRef<'a>>
pub fn as_object(self) -> Option<ObjectRef<'a>>
If the value is an object, returns the associated map. Returns None
otherwise.
Trait Implementations§
source§impl<'a> Ord for ValueRef<'a>
impl<'a> Ord for ValueRef<'a>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<&str> for ValueRef<'_>
impl PartialEq<&str> for ValueRef<'_>
source§impl PartialEq<String> for ValueRef<'_>
impl PartialEq<String> for ValueRef<'_>
source§impl PartialEq<ValueRef<'_>> for &str
impl PartialEq<ValueRef<'_>> for &str
source§impl PartialEq<ValueRef<'_>> for String
impl PartialEq<ValueRef<'_>> for String
source§impl PartialEq<ValueRef<'_>> for str
impl PartialEq<ValueRef<'_>> for str
source§impl PartialEq<bool> for ValueRef<'_>
impl PartialEq<bool> for ValueRef<'_>
source§impl PartialEq<isize> for ValueRef<'_>
impl PartialEq<isize> for ValueRef<'_>
source§impl PartialEq<usize> for ValueRef<'_>
impl PartialEq<usize> for ValueRef<'_>
source§impl<'a> PartialEq for ValueRef<'a>
impl<'a> PartialEq for ValueRef<'a>
source§impl<'a> PartialOrd for ValueRef<'a>
impl<'a> PartialOrd for ValueRef<'a>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more