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 not Copy.

  • Converting using IValue::into_{array,object,string,number}()

    These methods return a Result of the corresponding type (or the original IValue if the type is not the one expected). These methods also exist for the variants which are not Copy.

  • 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 be Copy.

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

JSON null.

JSON false.

JSON true.

Returns the type of this value.

Destructures this value into an enum which can be matched on.

Destructures a reference to this value into an enum which can be matched on.

Destructures a mutable reference to this value into an enum which can be matched 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.

Returns true if this is the null value.

Returns true if this is a boolean.

Returns true if this is the true value.

Returns true if this is the false value.

Converts this value to a bool. Returns None if it’s not a boolean.

Returns true if this is a number.

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.

Returns true if this is a string.

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.

Returns true if this is an array.

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.

Returns true if this is an object.

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.

Converts this value to an IObject. Returns Err(self) if it’s not an object.

Trait Implementations

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably 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

Mutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. 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

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.

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

Executes the destructor for this type. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

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

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

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

Serialize this value into the given Serde serializer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.