Skip to main content

IValue

Struct IValue 

Source
pub struct IValue(/* private fields */);
Expand description

An interned JSON value.

Implementations§

Source§

impl IValue

Source

pub fn null() -> Self

Interns a null JSON value.

Source

pub fn bool(b: bool) -> Self

Interns a boolean JSON value.

Source

pub fn u64(x: u64) -> Self

Interns an integer JSON value.

Source

pub fn i64(x: i64) -> Self

Interns an integer JSON value.

Source

pub fn f64(x: f64) -> Self

Interns a floating-point JSON value.

Source

pub fn string(interners: &Jinterners, s: &str) -> Self

Available on crate feature sync only.

Interns a string JSON value.

See also string_mut(), which is more efficient if you hold a mutable reference to the Jinterners arena as it avoids acquiring locks.

Source

pub fn string_mut(interners: &mut Jinterners, s: &str) -> Self

Interns a string JSON value.

Contrary to string(), no locks are held internally because this function already takes an exclusive mutable reference to the Jinterners arena.

Source

pub fn array(interners: &Jinterners, a: &[Self]) -> Self

Available on crate feature sync only.

Interns a JSON array, whose items are already interned.

See also array_mut(), which is more efficient if you hold a mutable reference to the Jinterners arena as it avoids acquiring locks.

Source

pub fn array_mut(interners: &mut Jinterners, a: &[Self]) -> Self

Interns a JSON array, whose items are already interned.

Contrary to array(), no locks are held internally because this function already takes an exclusive mutable reference to the Jinterners arena.

Source

pub fn object<'a>( interners: &Jinterners, o: impl Iterator<Item = (&'a str, Self)>, ) -> Self

Available on crate feature sync only.

Interns a JSON object, whose values are already interned.

See also object_mut(), which is more efficient if you hold a mutable reference to the Jinterners arena as it avoids acquiring locks.

Source

pub fn object_mut<'a>( interners: &mut Jinterners, o: impl Iterator<Item = (&'a str, Self)>, ) -> Self

Interns a JSON object, whose values are already interned.

Contrary to object(), no locks are held internally because this function already takes an exclusive mutable reference to the Jinterners arena.

Source

pub fn object_from_keys( interners: &Jinterners, o: impl Iterator<Item = (InternedStrKey, Self)>, ) -> Self

Available on crate feature sync only.

Interns a JSON object, whose keys and values are already interned.

See also object_from_keys_mut(), which is more efficient if you hold a mutable reference to the Jinterners arena as it avoids acquiring locks.

Source

pub fn object_from_keys_mut( interners: &mut Jinterners, o: impl Iterator<Item = (InternedStrKey, Self)>, ) -> Self

Interns a JSON object, whose keys and values are already interned.

Contrary to object_from_keys(), no locks are held internally because this function already takes an exclusive mutable reference to the Jinterners arena.

Source

pub fn from_value<T>(value: T, interners: &Jinterners) -> Result<Self, Error>
where T: Serialize,

Available on crate features serde and sync only.

Convert an arbitrary type into an IValue using that type’s Serialize implementation.

See also from_value_mut(), which is more efficient if you hold a mutable reference to the Jinterners arena as it avoids acquiring locks.

Source

pub fn from_value_mut<T>( value: T, interners: &mut Jinterners, ) -> Result<Self, Error>
where T: Serialize,

Available on crate feature serde only.

Convert an arbitrary type into an IValue using that type’s Serialize implementation.

Contrary to from_value(), no locks are held internally because this function already takes an exclusive mutable reference to the Jinterners arena.

Source

pub fn to_value<'de, T>(&self, interners: &'de Jinterners) -> Result<T, Error>
where T: Deserialize<'de>,

Available on crate feature serde only.

Convert an IValue into an arbitrary type using that type’s Deserialize implementation.

Source

pub fn from_json_slice( json: &[u8], interners: &Jinterners, ) -> Result<Self, Error>

Available on crate features serde and sync only.

Convenience function to combine a serde_json::Deserializer with an InterningDeserializer to deserialize an interned value from a plain JSON slice, using the provided Jinterners arena.

See also from_json_slice_mut(), which is more efficient if you hold a mutable reference to the Jinterners arena as it avoids acquiring locks.

Source

pub fn from_json_str(json: &str, interners: &Jinterners) -> Result<Self, Error>

Available on crate features serde and sync only.

Convenience function to combine a serde_json::Deserializer with an InterningDeserializer to deserialize an interned value from a plain JSON string, using the provided Jinterners arena.

See also from_json_str_mut(), which is more efficient if you hold a mutable reference to the Jinterners arena as it avoids acquiring locks.

Source

pub fn from_json_reader<R: Read>( json: R, interners: &Jinterners, ) -> Result<Self, Error>

Available on crate features serde and std and sync only.

Convenience function to combine a serde_json::Deserializer with an InterningDeserializer to deserialize an interned value from a plain JSON reader, using the provided Jinterners arena.

See also from_json_reader_mut(), which is more efficient if you hold a mutable reference to the Jinterners arena as it avoids acquiring locks.

Source

pub fn from_json_slice_mut( json: &[u8], interners: &mut Jinterners, ) -> Result<Self, Error>

Available on crate feature serde only.

Convenience function to combine a serde_json::Deserializer with an InterningDeserializerMut to deserialize an interned value from a plain JSON slice, using the provided Jinterners arena.

Contrary to from_json_slice(), no locks are held internally because this function already takes an exclusive mutable reference to the Jinterners arena.

Source

pub fn from_json_str_mut( json: &str, interners: &mut Jinterners, ) -> Result<Self, Error>

Available on crate feature serde only.

Convenience function to combine a serde_json::Deserializer with an InterningDeserializerMut to deserialize an interned value from a plain JSON string, using the provided Jinterners arena.

Contrary to from_json_str(), no locks are held internally because this function already takes an exclusive mutable reference to the Jinterners arena.

Source

pub fn from_json_reader_mut<R: Read>( json: R, interners: &mut Jinterners, ) -> Result<Self, Error>

Available on crate features serde and std only.

Convenience function to combine a serde_json::Deserializer with an InterningDeserializerMut to deserialize an interned value from a plain JSON reader, using the provided Jinterners arena.

Contrary to from_json_reader(), no locks are held internally because this function already takes an exclusive mutable reference to the Jinterners arena.

Source

pub fn to_json_bytes(&self, interners: &Jinterners) -> Result<Vec<u8>, Error>

Available on crate feature serde only.

Convenience function to call serde_json::to_vec() on a BoundValue combining this value with the given Jinterners.

Source

pub fn to_json_bytes_pretty( &self, interners: &Jinterners, ) -> Result<Vec<u8>, Error>

Available on crate feature serde only.

Convenience function to call serde_json::to_vec_pretty() on a BoundValue combining this value with the given Jinterners.

Source

pub fn to_json_string(&self, interners: &Jinterners) -> Result<String, Error>

Available on crate feature serde only.

Convenience function to call serde_json::to_string() on a BoundValue combining this value with the given Jinterners.

Source

pub fn to_json_string_pretty( &self, interners: &Jinterners, ) -> Result<String, Error>

Available on crate feature serde only.

Convenience function to call serde_json::to_string_pretty() on a BoundValue combining this value with the given Jinterners.

Source

pub fn to_json_writer<W: Write>( &self, writer: W, interners: &Jinterners, ) -> Result<(), Error>

Available on crate features serde and std only.

Convenience function to call serde_json::to_writer() on a BoundValue combining this value with the given Jinterners.

Source

pub fn to_json_writer_pretty<W: Write>( &self, writer: W, interners: &Jinterners, ) -> Result<(), Error>

Available on crate features serde and std only.

Convenience function to call serde_json::to_writer_pretty() on a BoundValue combining this value with the given Jinterners.

Trait Implementations§

Source§

impl Clone for IValue

Source§

fn clone(&self) -> IValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for IValue

Source§

impl Debug for IValue

Source§

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

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

impl Default for IValue

Source§

fn default() -> IValue

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for IValue

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for IValue

Source§

impl GetSize for IValue

Source§

fn get_heap_size(&self) -> usize

Determines how many bytes this object occupies inside the heap. Read more
Source§

fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>( &self, tracker: TRACKER, ) -> (usize, TRACKER)

Determines how many bytes this object occupies inside the heap while using a tracker. Read more
Source§

fn get_stack_size() -> usize

Determines how may bytes this object occupies inside the stack. Read more
Source§

fn get_size(&self) -> usize

Determines the total size of the object. Read more
Source§

fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)
where T: GetSizeTracker,

Determines the total size of the object while using a tracker. Read more
Source§

impl Hash for IValue

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 Ord for IValue

Source§

fn cmp(&self, other: &IValue) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

impl PartialEq for IValue

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for IValue

Source§

fn partial_cmp(&self, other: &IValue) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for IValue

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 StructuralPartialEq for IValue

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.