Struct json_syntax::object::Object
source · pub struct Object { /* private fields */ }
Expand description
Object.
Implementations§
source§impl Object
impl Object
pub fn new() -> Self
pub fn from_vec(entries: Vec<Entry>) -> Self
pub fn capacity(&self) -> usize
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get_fragment(&self, index: usize) -> Result<FragmentRef<'_>, usize>
pub fn entries(&self) -> &[Entry]
pub fn iter(&self) -> Iter<'_, Entry>
pub fn iter_mut(&mut self) -> IterMut<'_> ⓘ
sourcepub fn get<Q>(&self, key: &Q) -> Values<'_> ⓘ
pub fn get<Q>(&self, key: &Q) -> Values<'_> ⓘ
Returns an iterator over the values matching the given key.
Runs in O(1)
(average).
sourcepub fn get_mut<Q>(&mut self, key: &Q) -> ValuesMut<'_> ⓘ
pub fn get_mut<Q>(&mut self, key: &Q) -> ValuesMut<'_> ⓘ
Returns an iterator over the values matching the given key.
Runs in O(1)
(average).
sourcepub fn get_unique<Q>(
&self,
key: &Q
) -> Result<Option<&Value>, Duplicate<&Entry>>
pub fn get_unique<Q>( &self, key: &Q ) -> Result<Option<&Value>, Duplicate<&Entry>>
Returns the unique entry value matching the given key.
Returns an error if multiple entries match the key.
Runs in O(1)
(average).
sourcepub fn get_unique_mut<Q>(
&mut self,
key: &Q
) -> Result<Option<&mut Value>, Duplicate<&Entry>>
pub fn get_unique_mut<Q>( &mut self, key: &Q ) -> Result<Option<&mut Value>, Duplicate<&Entry>>
Returns the unique entry value matching the given key.
Returns an error if multiple entries match the key.
Runs in O(1)
(average).
sourcepub fn get_entries<Q>(&self, key: &Q) -> Entries<'_> ⓘ
pub fn get_entries<Q>(&self, key: &Q) -> Entries<'_> ⓘ
Returns an iterator over the entries matching the given key.
Runs in O(1)
(average).
sourcepub fn get_unique_entry<Q>(
&self,
key: &Q
) -> Result<Option<&Entry>, Duplicate<&Entry>>
pub fn get_unique_entry<Q>( &self, key: &Q ) -> Result<Option<&Entry>, Duplicate<&Entry>>
Returns the unique entry matching the given key.
Returns an error if multiple entries match the key.
Runs in O(1)
(average).
sourcepub fn get_with_index<Q>(&self, key: &Q) -> ValuesWithIndex<'_> ⓘ
pub fn get_with_index<Q>(&self, key: &Q) -> ValuesWithIndex<'_> ⓘ
Returns an iterator over the entries matching the given key.
Runs in O(1)
(average).
sourcepub fn get_entries_with_index<Q>(&self, key: &Q) -> EntriesWithIndex<'_> ⓘ
pub fn get_entries_with_index<Q>(&self, key: &Q) -> EntriesWithIndex<'_> ⓘ
Returns an iterator over the entries matching the given key.
Runs in O(1)
(average).
pub fn index_of<Q>(&self, key: &Q) -> Option<usize>
pub fn redundant_index_of<Q>(&self, key: &Q) -> Option<usize>
pub fn indexes_of<Q>(&self, key: &Q) -> Indexes<'_> ⓘ
pub fn first(&self) -> Option<&Entry>
pub fn last(&self) -> Option<&Entry>
sourcepub fn push(&mut self, key: Key, value: Value) -> bool
pub fn push(&mut self, key: Key, value: Value) -> bool
Push the given key-value pair to the end of the object.
Returns true
if the key was not already present in the object,
and false
otherwise.
Any previous entry matching the key is not overridden: duplicates
are preserved, in order.
Runs in O(1)
.
pub fn push_entry(&mut self, entry: Entry) -> bool
sourcepub fn push_front(&mut self, key: Key, value: Value) -> bool
pub fn push_front(&mut self, key: Key, value: Value) -> bool
Push the given key-value pair to the top of the object.
Returns true
if the key was not already present in the object,
and false
otherwise.
Any previous entry matching the key is not overridden: duplicates
are preserved, in order.
Runs in O(n)
.
pub fn push_entry_front(&mut self, entry: Entry) -> bool
sourcepub fn remove_at(&mut self, index: usize) -> Option<Entry>
pub fn remove_at(&mut self, index: usize) -> Option<Entry>
Removes the entry at the given index.
sourcepub fn insert(
&mut self,
key: Key,
value: Value
) -> Option<RemovedByInsertion<'_>>
pub fn insert( &mut self, key: Key, value: Value ) -> Option<RemovedByInsertion<'_>>
Inserts the given key-value pair.
If one or more entries are already matching the given key,
all of them are removed and returned in the resulting iterator.
Otherwise, None
is returned.
sourcepub fn insert_front(
&mut self,
key: Key,
value: Value
) -> RemovedByInsertFront<'_> ⓘ
pub fn insert_front( &mut self, key: Key, value: Value ) -> RemovedByInsertFront<'_> ⓘ
Inserts the given key-value pair on top of the object.
If one or more entries are already matching the given key, all of them are removed and returned in the resulting iterator.
sourcepub fn remove<'q, Q>(&mut self, key: &'q Q) -> RemovedEntries<'_, 'q, Q> ⓘ
pub fn remove<'q, Q>(&mut self, key: &'q Q) -> RemovedEntries<'_, 'q, Q> ⓘ
Remove all entries associated to the given key.
Runs in O(n)
time (average).
Trait Implementations§
source§impl Extend<(SmallString<[u8; 16]>, Value)> for Object
impl Extend<(SmallString<[u8; 16]>, Value)> for Object
source§fn extend<I: IntoIterator<Item = (Key, Value)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (Key, Value)>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl Extend<Entry> for Object
impl Extend<Entry> for Object
source§fn extend<I: IntoIterator<Item = Entry>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Entry>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl FromIterator<(SmallString<[u8; 16]>, Value)> for Object
impl FromIterator<(SmallString<[u8; 16]>, Value)> for Object
source§impl FromIterator<Entry> for Object
impl FromIterator<Entry> for Object
source§impl<'a> IntoIterator for &'a Object
impl<'a> IntoIterator for &'a Object
source§impl<'a> IntoIterator for &'a mut Object
impl<'a> IntoIterator for &'a mut Object
source§impl IntoIterator for Object
impl IntoIterator for Object
source§impl Ord for Object
impl Ord for Object
source§impl PartialEq for Object
impl PartialEq for Object
source§impl PartialOrd for Object
impl PartialOrd for Object
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more