[][src]Struct ijson::object::IObject

#[repr(transparent)]pub struct IObject(_);

The IObject type is similar to a HashMap<IString, IValue>. As with the IArray, the length and capacity are stored inside the heap allocation. In addition, IObjects preserve the insertion order of their elements, in case that is important in the original JSON.

Removing from an IObject will disrupt the insertion order.

Implementations

impl IObject[src]

pub fn new() -> Self[src]

Constructs a new empty IObject. Does not allocate.

pub fn with_capacity(cap: usize) -> Self[src]

Constructs a new IObject with the specified capacity. At least that many entries can be added to the object without reallocating.

pub fn capacity(&self) -> usize[src]

Returns the capacity of the object. This is the maximum number of entries the object can hold without reallocating.

pub fn len(&self) -> usize[src]

Returns the number of entries currently stored in the object.

pub fn is_empty(&self) -> bool[src]

Returns true if the object is empty.

pub fn reserve(&mut self, additional: usize)[src]

Reserves space for at least this many additional entries.

pub fn entry(&mut self, key: impl Into<IString>) -> Entry<'_>[src]

Returns a view of an entry within this object.

pub fn entry_or_clone(&mut self, key: &IString) -> Entry<'_>[src]

Returns a view of an entry within this object, whilst avoiding cloning the key if the entry is already occupied.

pub fn keys(&self) -> impl Iterator<Item = &IString>[src]

Returns an iterator over references to the keys in this object.

pub fn values(&self) -> impl Iterator<Item = &IValue>[src]

Returns an iterator over references to the values in this object.

pub fn iter(&self) -> Iter<'_>

Notable traits for Iter<'a>

impl<'a> Iterator for Iter<'a> type Item = (&'a IString, &'a IValue);
[src]

Returns an iterator over (&key, &value) pairs in this object.

pub fn values_mut(&mut self) -> impl Iterator<Item = &mut IValue>[src]

Returns an iterator over mutable references to the values in this object.

pub fn iter_mut(&mut self) -> IterMut<'_>

Notable traits for IterMut<'a>

impl<'a> Iterator for IterMut<'a> type Item = (&'a IString, &'a mut IValue);
[src]

Returns an iterator over (&key, &mut value) pairs in this object.

pub fn clear(&mut self)[src]

Removes all entries from the object. The capacity is unchanged.

pub fn get_key_value(&self, k: impl ObjectIndex) -> Option<(&IString, &IValue)>[src]

Looks up the specified key in this object and returns a (&key, &value) pair if found.

pub fn get_key_value_mut(
    &mut self,
    k: impl ObjectIndex
) -> Option<(&IString, &mut IValue)>
[src]

Looks up the specified key in this object and returns a (&key, &mut value) pair if found.

pub fn get(&self, k: impl ObjectIndex) -> Option<&IValue>[src]

Looks up the specified key in this object and returns a reference to the corresponding value if found.

pub fn get_mut(&mut self, k: impl ObjectIndex) -> Option<&mut IValue>[src]

Looks up the specified key in this object and returns a mutable reference to the corresponding value if found.

pub fn contains_key(&self, k: impl ObjectIndex) -> bool[src]

Returns true if the specified key exists in the object.

pub fn insert(
    &mut self,
    k: impl Into<IString>,
    v: impl Into<IValue>
) -> Option<IValue>
[src]

Inserts a new value into this object with the specified key. If a value already existed at this key, that value is replaced and returend.

pub fn remove_entry(&mut self, k: impl ObjectIndex) -> Option<(IString, IValue)>[src]

Removes the entry at the specified key, returning both the key and value if found.

pub fn remove(&mut self, k: impl ObjectIndex) -> Option<IValue>[src]

Removes the entry at the specified key, returning the value if found.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the memory allocation used by the object such that its capacity becomes equal to its length.

pub fn retain(&mut self, f: impl FnMut(&IString, &mut IValue) -> bool)[src]

Calls the specified function for each entry in the object. Each entry where the function returns false is removed from the object.

The function also has the ability to modify the values in-place.

Trait Implementations

impl AsMut<IValue> for IObject[src]

impl AsRef<IValue> for IObject[src]

impl Borrow<IValue> for IObject[src]

impl BorrowMut<IValue> for IObject[src]

impl Clone for IObject[src]

impl Debug for IObject[src]

impl Default for IObject[src]

impl<'de> Deserialize<'de> for IObject[src]

impl<'de> Deserializer<'de> for &'de IObject[src]

type Error = Error

The error type that can be returned if some error occurs during deserialization. Read more

impl Eq for IObject[src]

impl<K: Into<IString>, V: Into<IValue>> Extend<(K, V)> for IObject[src]

impl<K: Into<IString>, V: Into<IValue>> From<BTreeMap<K, V>> for IObject[src]

impl<K: Into<IString>, V: Into<IValue>> From<HashMap<K, V, RandomState>> for IObject[src]

impl From<IObject> for IValue[src]

impl<K: Into<IString>, V: Into<IValue>> FromIterator<(K, V)> for IObject[src]

impl Hash for IObject[src]

impl<I: ObjectIndex> Index<I> for IObject[src]

type Output = IValue

The returned type after indexing.

impl<I: ObjectIndex> IndexMut<I> for IObject[src]

impl IntoIterator for IObject[src]

type Item = (IString, IValue)

The type of the elements being iterated over.

type IntoIter = IntoIter

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a IObject[src]

type Item = (&'a IString, &'a IValue)

The type of the elements being iterated over.

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a mut IObject[src]

type Item = (&'a IString, &'a mut IValue)

The type of the elements being iterated over.

type IntoIter = IterMut<'a>

Which kind of iterator are we turning this into?

impl PartialEq<IObject> for IObject[src]

impl PartialOrd<IObject> for IObject[src]

impl Serialize for IObject[src]

impl<'a> TryFrom<&'a IValue> for &'a IObject[src]

type Error = ()

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a mut IValue> for &'a mut IObject[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<IValue> for IObject[src]

type Error = IValue

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for IObject

impl Send for IObject

impl Sync for IObject

impl Unpin for IObject

impl UnwindSafe for IObject

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.