Struct ijson::IValue [−][src]
#[repr(transparent)]pub struct IValue { /* fields omitted */ }
Expand description
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
Destructures this value into an enum which can be match
ed on.
Destructures a reference to this value into an enum which can be match
ed on.
Destructures a mutable reference to this value into an enum which can be match
ed on.
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.
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.
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.
Takes this value, replacing it with IValue::NULL
.
Returns the length of this value if it is an array or object.
Returns None
for other types.
Returns whether this value is empty if it is an array or object.
Returns None
for other types.
Converts this value to a bool
.
Returns None
if it’s not a boolean.
Gets a reference to this value as an INumber
.
Returns None
if it’s not a number.
Gets a mutable reference to this value as an INumber
.
Returns None
if it’s not a number.
Converts this value to an INumber
.
Returns Err(self)
if it’s not a number.
Converts this value to an i64 if it is a number that can be represented exactly.
Converts this value to a u64 if it is a number that can be represented exactly.
Converts this value to an f64 if it is a number that can be represented exactly.
Converts this value to an f32 if it is a number that can be represented exactly.
Converts this value to an i32 if it is a number that can be represented exactly.
Converts this value to a u32 if it is a number that can be represented exactly.
Converts this value to an isize if it is a number that can be represented exactly.
Converts this value to a usize if it is a number that can be represented exactly.
Converts this value to an f64 if it is a number, potentially losing precision in the process.
Converts this value to an f32 if it is a number, potentially losing precision in the process.
Gets a reference to this value as an IString
.
Returns None
if it’s not a string.
Gets a mutable reference to this value as an IString
.
Returns None
if it’s not a string.
Converts this value to an IString
.
Returns Err(self)
if it’s not a string.
Gets a reference to this value as an IArray
.
Returns None
if it’s not an array.
Gets a mutable reference to this value as an IArray
.
Returns None
if it’s not an array.
Converts this value to an IArray
.
Returns Err(self)
if it’s not an array.
Gets a reference to this value as an IObject
.
Returns None
if it’s not an object.
Gets a mutable reference to this value as an IObject
.
Returns None
if it’s not an object.
Trait Implementations
Mutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Deserialize this value from the given Serde deserializer. Read more
The error type that can be returned if some error occurs during deserialization. Read more
Require the Deserializer
to figure out how to drive the visitor based
on what data type is in the input. Read more
Hint that the Deserialize
type is expecting an i8
value.
Hint that the Deserialize
type is expecting an i16
value.
Hint that the Deserialize
type is expecting an i32
value.
Hint that the Deserialize
type is expecting an i64
value.
Hint that the Deserialize
type is expecting a u8
value.
Hint that the Deserialize
type is expecting a u16
value.
Hint that the Deserialize
type is expecting a u32
value.
Hint that the Deserialize
type is expecting a u64
value.
Hint that the Deserialize
type is expecting a f32
value.
Hint that the Deserialize
type is expecting a f64
value.
Hint that the Deserialize
type is expecting an optional value. Read more
fn deserialize_enum<V>(
self,
name: &'static str,
variants: &'static [&'static str],
visitor: V
) -> Result<V::Value, Error> where
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>,
Hint that the Deserialize
type is expecting an enum value with a
particular name and possible variants. Read more
Hint that the Deserialize
type is expecting a newtype struct with a
particular name. Read more
Hint that the Deserialize
type is expecting a bool
value.
Hint that the Deserialize
type is expecting a char
value.
Hint that the Deserialize
type is expecting a string value and does
not benefit from taking ownership of buffered data owned by the
Deserializer
. Read more
Hint that the Deserialize
type is expecting a string value and would
benefit from taking ownership of buffered data owned by the
Deserializer
. Read more
Hint that the Deserialize
type is expecting a byte array and does not
benefit from taking ownership of buffered data owned by the
Deserializer
. Read more
Hint that the Deserialize
type is expecting a byte array and would
benefit from taking ownership of buffered data owned by the
Deserializer
. Read more
Hint that the Deserialize
type is expecting a unit value.
Hint that the Deserialize
type is expecting a unit struct with a
particular name. Read more
Hint that the Deserialize
type is expecting a sequence of values.
Hint that the Deserialize
type is expecting a sequence of values and
knows how many values there are without looking at the serialized data. Read more
Hint that the Deserialize
type is expecting a tuple struct with a
particular name and number of fields. Read more
Hint that the Deserialize
type is expecting a map of key-value pairs.
fn deserialize_struct<V>(
self,
name: &'static str,
fields: &'static [&'static str],
visitor: V
) -> Result<V::Value, Error> where
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>,
Hint that the Deserialize
type is expecting a struct with a particular
name and fields. Read more
Hint that the Deserialize
type is expecting the name of a struct
field or the discriminant of an enum variant. Read more
Hint that the Deserialize
type needs to deserialize a value whose type
doesn’t matter because it is ignored. Read more
Hint that the Deserialize
type is expecting an i128
value. Read more
Hint that the Deserialize
type is expecting an u128
value. Read more
Determine whether Deserialize
implementations should expect to
deserialize their human-readable form. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
Blanket Implementations
Mutably borrows from an owned value. Read more