Struct ijson::IValue [−][src]
#[repr(transparent)]pub struct IValue { /* fields omitted */ }
Stores an arbitrary JSON value.
Compared to serde_json::Value
this type is a struct rather than an enum, as
this is necessary to achieve the important size reductions. This means that
you cannot directly match
on an IValue
to determine its type.
Instead, an IValue
offers several ways to get at the inner type:
-
Destructuring using
IValue::destructure[{_ref,_mut}]()
These methods return wrapper enums which you can directly match on, so these methods are the most direct replacement for matching on a
Value
. -
Borrowing using
IValue::as_{array,object,string,number}[_mut]()
These methods return an
Option
of the corresponding reference if the type matches the one expected. These methods exist for the variants which are notCopy
. -
Converting using
IValue::into_{array,object,string,number}()
These methods return a
Result
of the corresponding type (or the originalIValue
if the type is not the one expected). These methods also exist for the variants which are notCopy
. -
Getting using
IValue::to_{bool,{i,u,f}{32,64}}[_lossy]}()
These methods return an
Option
of the corresponding type. These methods exist for types where the return value would beCopy
.
You can also check the type of the inner value without specifically accessing it using one of these methods:
-
Checking using
IValue::is_{null,bool,number,string,array,object,true,false}()
These methods exist for all types.
-
Getting the type with
IValue::type_
This method returns the
ValueType
enum, which has a variant for each of the six JSON types.
Implementations
impl IValue
[src]
pub const NULL: Self
[src]
JSON null
.
pub const FALSE: Self
[src]
JSON false
.
pub const TRUE: Self
[src]
JSON true
.
pub fn type_(&self) -> ValueType
[src]
Returns the type of this value.
pub fn destructure(self) -> Destructured
[src]
Destructures this value into an enum which can be match
ed on.
pub fn destructure_ref(&self) -> DestructuredRef<'_>
[src]
Destructures a reference to this value into an enum which can be match
ed on.
pub fn destructure_mut(&mut self) -> DestructuredMut<'_>
[src]
Destructures a mutable reference to this value into an enum which can be match
ed on.
pub fn get(&self, index: impl ValueIndex) -> Option<&IValue>
[src]
Indexes into this value with a number or string.
Panics if the value is not an array or object.
Panics if attempting to index an array with a string.
Panics if attempting to index an object with a number.
Returns None
if the index type is correct, but there is
no value at this index.
pub fn get_mut(&mut self, index: impl ValueIndex) -> Option<&mut IValue>
[src]
Mutably indexes into this value with a number or string.
Panics if the value is not an array or object.
Panics if attempting to index an array with a string.
Panics if attempting to index an object with a number.
Returns None
if the index type is correct, but there is
no value at this index.
pub fn remove(&mut self, index: impl ValueIndex) -> Option<IValue>
[src]
Removes a value at the specified numberic or string index.
Panics if this is not an array or object.
Panics if attempting to index an array with a string.
Panics if attempting to index an object with a number.
Returns None
if the index type is correct, but there is
no value at this index.
pub fn take(&mut self) -> IValue
[src]
Takes this value, replacing it with IValue::NULL
.
pub fn len(&self) -> Option<usize>
[src]
Returns the length of this value if it is an array or object.
Returns None
for other types.
pub fn is_empty(&self) -> Option<bool>
[src]
Returns whether this value is empty if it is an array or object.
Returns None
for other types.
pub fn is_null(&self) -> bool
[src]
Returns true
if this is the null
value.
pub fn is_bool(&self) -> bool
[src]
Returns true
if this is a boolean.
pub fn is_true(&self) -> bool
[src]
Returns true
if this is the true
value.
pub fn is_false(&self) -> bool
[src]
Returns true
if this is the false
value.
pub fn to_bool(&self) -> Option<bool>
[src]
Converts this value to a bool
.
Returns None
if it’s not a boolean.
pub fn is_number(&self) -> bool
[src]
Returns true
if this is a number.
pub fn as_number(&self) -> Option<&INumber>
[src]
Gets a reference to this value as an INumber
.
Returns None
if it’s not a number.
pub fn as_number_mut(&mut self) -> Option<&mut INumber>
[src]
Gets a mutable reference to this value as an INumber
.
Returns None
if it’s not a number.
pub fn into_number(self) -> Result<INumber, IValue>
[src]
Converts this value to an INumber
.
Returns Err(self)
if it’s not a number.
pub fn to_i64(&self) -> Option<i64>
[src]
Converts this value to an i64 if it is a number that can be represented exactly.
pub fn to_u64(&self) -> Option<u64>
[src]
Converts this value to a u64 if it is a number that can be represented exactly.
pub fn to_f64(&self) -> Option<f64>
[src]
Converts this value to an f64 if it is a number that can be represented exactly.
pub fn to_f32(&self) -> Option<f32>
[src]
Converts this value to an f32 if it is a number that can be represented exactly.
pub fn to_i32(&self) -> Option<i32>
[src]
Converts this value to an i32 if it is a number that can be represented exactly.
pub fn to_u32(&self) -> Option<u32>
[src]
Converts this value to a u32 if it is a number that can be represented exactly.
pub fn to_isize(&self) -> Option<isize>
[src]
Converts this value to an isize if it is a number that can be represented exactly.
pub fn to_usize(&self) -> Option<usize>
[src]
Converts this value to a usize if it is a number that can be represented exactly.
pub fn to_f64_lossy(&self) -> Option<f64>
[src]
Converts this value to an f64 if it is a number, potentially losing precision in the process.
pub fn to_f32_lossy(&self) -> Option<f32>
[src]
Converts this value to an f32 if it is a number, potentially losing precision in the process.
pub fn is_string(&self) -> bool
[src]
Returns true
if this is a string.
pub fn as_string(&self) -> Option<&IString>
[src]
Gets a reference to this value as an IString
.
Returns None
if it’s not a string.
pub fn as_string_mut(&mut self) -> Option<&mut IString>
[src]
Gets a mutable reference to this value as an IString
.
Returns None
if it’s not a string.
pub fn into_string(self) -> Result<IString, IValue>
[src]
Converts this value to an IString
.
Returns Err(self)
if it’s not a string.
pub fn is_array(&self) -> bool
[src]
Returns true
if this is an array.
pub fn as_array(&self) -> Option<&IArray>
[src]
Gets a reference to this value as an IArray
.
Returns None
if it’s not an array.
pub fn as_array_mut(&mut self) -> Option<&mut IArray>
[src]
Gets a mutable reference to this value as an IArray
.
Returns None
if it’s not an array.
pub fn into_array(self) -> Result<IArray, IValue>
[src]
Converts this value to an IArray
.
Returns Err(self)
if it’s not an array.
pub fn is_object(&self) -> bool
[src]
Returns true
if this is an object.
pub fn as_object(&self) -> Option<&IObject>
[src]
Gets a reference to this value as an IObject
.
Returns None
if it’s not an object.
pub fn as_object_mut(&mut self) -> Option<&mut IObject>
[src]
Gets a mutable reference to this value as an IObject
.
Returns None
if it’s not an object.
pub fn into_object(self) -> Result<IObject, IValue>
[src]
Converts this value to an IObject
.
Returns Err(self)
if it’s not an object.
Trait Implementations
impl AsMut<IValue> for IArray
[src]
impl AsMut<IValue> for INumber
[src]
impl AsMut<IValue> for IObject
[src]
impl AsMut<IValue> for IString
[src]
impl AsRef<IValue> for IArray
[src]
impl AsRef<IValue> for INumber
[src]
impl AsRef<IValue> for IObject
[src]
impl AsRef<IValue> for IString
[src]
impl Borrow<IValue> for IArray
[src]
impl Borrow<IValue> for INumber
[src]
impl Borrow<IValue> for IObject
[src]
impl Borrow<IValue> for IString
[src]
impl BorrowMut<IValue> for IArray
[src]
fn borrow_mut(&mut self) -> &mut IValue
[src]
impl BorrowMut<IValue> for INumber
[src]
fn borrow_mut(&mut self) -> &mut IValue
[src]
impl BorrowMut<IValue> for IObject
[src]
fn borrow_mut(&mut self) -> &mut IValue
[src]
impl BorrowMut<IValue> for IString
[src]
fn borrow_mut(&mut self) -> &mut IValue
[src]
impl Clone for IValue
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for IValue
[src]
impl Default for IValue
[src]
impl<'de> Deserialize<'de> for IValue
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl<'de> Deserializer<'de> for &'de IValue
[src]
type Error = Error
The error type that can be returned if some error occurs during deserialization. Read more
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_enum<V>(
self,
name: &'static str,
variants: &'static [&'static str],
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
self,
name: &'static str,
variants: &'static [&'static str],
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
fn deserialize_newtype_struct<V>(
self,
_name: &'static str,
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
self,
_name: &'static str,
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_unit_struct<V>(
self,
_name: &'static str,
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
self,
_name: &'static str,
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_tuple<V>(
self,
_len: usize,
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
self,
_len: usize,
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
fn deserialize_tuple_struct<V>(
self,
_name: &'static str,
_len: usize,
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
self,
_name: &'static str,
_len: usize,
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_struct<V>(
self,
name: &'static str,
fields: &'static [&'static str],
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
self,
name: &'static str,
fields: &'static [&'static str],
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
[src]
V: Visitor<'de>,
pub fn deserialize_i128<V>(
self,
visitor: V
) -> Result<<V as Visitor<'de>>::Value, Self::Error> where
V: Visitor<'de>,
[src]
self,
visitor: V
) -> Result<<V as Visitor<'de>>::Value, Self::Error> where
V: Visitor<'de>,
pub fn deserialize_u128<V>(
self,
visitor: V
) -> Result<<V as Visitor<'de>>::Value, Self::Error> where
V: Visitor<'de>,
[src]
self,
visitor: V
) -> Result<<V as Visitor<'de>>::Value, Self::Error> where
V: Visitor<'de>,
pub fn is_human_readable(&self) -> bool
[src]
impl Drop for IValue
[src]
impl Eq for IValue
[src]
impl<T: Into<IValue> + Clone> From<&'_ [T]> for IValue
[src]
impl From<&'_ String> for IValue
[src]
impl From<&'_ mut String> for IValue
[src]
impl From<&'_ mut str> for IValue
[src]
impl From<&'_ str> for IValue
[src]
impl<K: Into<IString>, V: Into<IValue>> From<BTreeMap<K, V>> for IValue
[src]
impl<K: Into<IString>, V: Into<IValue>> From<HashMap<K, V, RandomState>> for IValue
[src]
impl From<IArray> for IValue
[src]
impl From<INumber> for IValue
[src]
impl From<IObject> for IValue
[src]
impl From<IString> for IValue
[src]
impl<T: Into<IValue>> From<Option<T>> for IValue
[src]
impl From<String> for IValue
[src]
impl<T: Into<IValue>> From<Vec<T, Global>> for IValue
[src]
impl From<bool> for IValue
[src]
impl From<f32> for IValue
[src]
impl From<f64> for IValue
[src]
impl From<i16> for IValue
[src]
impl From<i32> for IValue
[src]
impl From<i64> for IValue
[src]
impl From<i8> for IValue
[src]
impl From<isize> for IValue
[src]
impl From<u16> for IValue
[src]
impl From<u32> for IValue
[src]
impl From<u64> for IValue
[src]
impl From<u8> for IValue
[src]
impl From<usize> for IValue
[src]
impl Hash for IValue
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<I: ValueIndex> Index<I> for IValue
[src]
impl<I: ValueIndex> IndexMut<I> for IValue
[src]
impl PartialEq<IValue> for IValue
[src]
impl PartialOrd<IValue> for IValue
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Send for IValue
[src]
impl Serialize for IValue
[src]
impl Sync for IValue
[src]
impl<'a> TryFrom<&'a IValue> for &'a IArray
[src]
type Error = ()
The type returned in the event of a conversion error.
fn try_from(other: &'a IValue) -> Result<Self, ()>
[src]
impl<'a> TryFrom<&'a IValue> for &'a INumber
[src]
type Error = ()
The type returned in the event of a conversion error.
fn try_from(other: &'a IValue) -> Result<Self, ()>
[src]
impl<'a> TryFrom<&'a IValue> for &'a IObject
[src]
type Error = ()
The type returned in the event of a conversion error.
fn try_from(other: &'a IValue) -> Result<Self, ()>
[src]
impl<'a> TryFrom<&'a IValue> for &'a IString
[src]
type Error = ()
The type returned in the event of a conversion error.
fn try_from(other: &'a IValue) -> Result<Self, ()>
[src]
impl<'a> TryFrom<&'a mut IValue> for &'a mut IArray
[src]
type Error = ()
The type returned in the event of a conversion error.
fn try_from(other: &'a mut IValue) -> Result<Self, ()>
[src]
impl<'a> TryFrom<&'a mut IValue> for &'a mut INumber
[src]
type Error = ()
The type returned in the event of a conversion error.
fn try_from(other: &'a mut IValue) -> Result<Self, ()>
[src]
impl<'a> TryFrom<&'a mut IValue> for &'a mut IObject
[src]
type Error = ()
The type returned in the event of a conversion error.
fn try_from(other: &'a mut IValue) -> Result<Self, ()>
[src]
impl<'a> TryFrom<&'a mut IValue> for &'a mut IString
[src]
type Error = ()
The type returned in the event of a conversion error.
fn try_from(other: &'a mut IValue) -> Result<Self, ()>
[src]
impl TryFrom<IValue> for IArray
[src]
type Error = IValue
The type returned in the event of a conversion error.
fn try_from(other: IValue) -> Result<Self, IValue>
[src]
impl TryFrom<IValue> for INumber
[src]
type Error = IValue
The type returned in the event of a conversion error.
fn try_from(other: IValue) -> Result<Self, IValue>
[src]
impl TryFrom<IValue> for IObject
[src]
type Error = IValue
The type returned in the event of a conversion error.
fn try_from(other: IValue) -> Result<Self, IValue>
[src]
impl TryFrom<IValue> for IString
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,