Struct json_ld_syntax::Object
source · pub struct Object<M = ()> { /* private fields */ }
Expand description
Object.
Implementations§
source§impl<M> Object<M>
impl<M> Object<M>
pub fn new() -> Object<M>
pub fn from_vec(entries: Vec<Entry<M>, Global>) -> Object<M>
pub fn capacity(&self) -> usize
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn entries(&self) -> &[Entry<M>]
pub fn iter(&self) -> Iter<'_, Entry<M>>
pub fn iter_mut(&mut self) -> IterMut<'_, M> ⓘ
sourcepub fn get<Q>(&self, key: &Q) -> Values<'_, M> ⓘwhere
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
pub fn get<Q>(&self, key: &Q) -> Values<'_, M> ⓘwhere
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
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<'_, M> ⓘwhere
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
pub fn get_mut<Q>(&mut self, key: &Q) -> ValuesMut<'_, M> ⓘwhere
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
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<&Meta<Value<M>, M>>, Duplicate<&Entry<M>>>where
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
pub fn get_unique<Q>(
&self,
key: &Q
) -> Result<Option<&Meta<Value<M>, M>>, Duplicate<&Entry<M>>>where
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
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 Meta<Value<M>, M>>, Duplicate<&Entry<M>>>where
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
pub fn get_unique_mut<Q>(
&mut self,
key: &Q
) -> Result<Option<&mut Meta<Value<M>, M>>, Duplicate<&Entry<M>>>where
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
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<'_, M> ⓘwhere
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
pub fn get_entries<Q>(&self, key: &Q) -> Entries<'_, M> ⓘwhere
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
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<M>>, Duplicate<&Entry<M>>>where
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
pub fn get_unique_entry<Q>(
&self,
key: &Q
) -> Result<Option<&Entry<M>>, Duplicate<&Entry<M>>>where
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
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<'_, M> ⓘwhere
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
pub fn get_with_index<Q>(&self, key: &Q) -> ValuesWithIndex<'_, M> ⓘwhere
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
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<'_, M> ⓘwhere
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
pub fn get_entries_with_index<Q>(&self, key: &Q) -> EntriesWithIndex<'_, M> ⓘwhere
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
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>where
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
pub fn redundant_index_of<Q>(&self, key: &Q) -> Option<usize>where
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
pub fn indexes_of<Q>(&self, key: &Q) -> Indexes<'_> ⓘwhere
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
pub fn first(&self) -> Option<&Entry<M>>
pub fn last(&self) -> Option<&Entry<M>>
sourcepub fn push(
&mut self,
key: Meta<SmallString<[u8; 16]>, M>,
value: Meta<Value<M>, M>
) -> bool
pub fn push(
&mut self,
key: Meta<SmallString<[u8; 16]>, M>,
value: Meta<Value<M>, M>
) -> 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<M>) -> bool
sourcepub fn remove_at(&mut self, index: usize) -> Option<Entry<M>>
pub fn remove_at(&mut self, index: usize) -> Option<Entry<M>>
Removes the entry at the given index.
sourcepub fn insert(
&mut self,
key: Meta<SmallString<[u8; 16]>, M>,
value: Meta<Value<M>, M>
) -> Option<RemovedByInsertion<'_, M>>
pub fn insert(
&mut self,
key: Meta<SmallString<[u8; 16]>, M>,
value: Meta<Value<M>, M>
) -> Option<RemovedByInsertion<'_, M>>
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 remove<Q, 'q>(&mut self, key: &'q Q) -> RemovedEntries<'_, 'q, M, Q> ⓘwhere
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
pub fn remove<Q, 'q>(&mut self, key: &'q Q) -> RemovedEntries<'_, 'q, M, Q> ⓘwhere
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
Remove all entries associated to the given key.
Runs in O(n)
time (average).
sourcepub fn remove_unique<Q>(
&mut self,
key: &Q
) -> Result<Option<Entry<M>>, Duplicate<Entry<M>>>where
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
pub fn remove_unique<Q>(
&mut self,
key: &Q
) -> Result<Option<Entry<M>>, Duplicate<Entry<M>>>where
Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,
Remove the unique entry associated to the given key.
Returns an error if multiple entries match the key.
Runs in O(n)
time (average).
sourcepub fn map_metadata<N>(self, f: impl FnMut(M) -> N) -> Object<N>
pub fn map_metadata<N>(self, f: impl FnMut(M) -> N) -> Object<N>
Recursively maps the metadata inside the object.
Trait Implementations§
source§impl<M> Extend<(Meta<SmallString<[u8; 16]>, M>, Meta<Value<M>, M>)> for Object<M>
impl<M> Extend<(Meta<SmallString<[u8; 16]>, M>, Meta<Value<M>, M>)> for Object<M>
source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = (Meta<SmallString<[u8; 16]>, M>, Meta<Value<M>, M>)>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = (Meta<SmallString<[u8; 16]>, M>, Meta<Value<M>, M>)>,
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<M> Extend<Entry<M>> for Object<M>
impl<M> Extend<Entry<M>> for Object<M>
source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = Entry<M>>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = Entry<M>>,
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<M> FromIterator<Entry<M>> for Object<M>
impl<M> FromIterator<Entry<M>> for Object<M>
source§impl<'a, M> IntoIterator for &'a Object<M>
impl<'a, M> IntoIterator for &'a Object<M>
source§impl<'a, M> IntoIterator for &'a mut Object<M>
impl<'a, M> IntoIterator for &'a mut Object<M>
source§impl<M> IntoIterator for Object<M>
impl<M> IntoIterator for Object<M>
source§impl<M> Ord for Object<M>where
M: Ord,
impl<M> Ord for Object<M>where
M: Ord,
source§impl<M> PartialEq<Object<M>> for Object<M>where
M: PartialEq<M>,
impl<M> PartialEq<Object<M>> for Object<M>where
M: PartialEq<M>,
source§impl<M> PartialOrd<Object<M>> for Object<M>where
M: PartialOrd<M>,
impl<M> PartialOrd<Object<M>> for Object<M>where
M: PartialOrd<M>,
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 moresource§impl<M> PrintWithSize for Object<M>
impl<M> PrintWithSize for Object<M>
source§impl<M> StrippedHash for Object<M>
impl<M> StrippedHash for Object<M>
fn stripped_hash<H>(&self, state: &mut H)where
H: Hasher,
source§impl<M> StrippedOrd for Object<M>
impl<M> StrippedOrd for Object<M>
fn stripped_cmp(&self, other: &Object<M>) -> Ordering
source§impl<M, __M> StrippedPartialEq<Object<__M>> for Object<M>
impl<M, __M> StrippedPartialEq<Object<__M>> for Object<M>
fn stripped_eq(&self, other: &Object<__M>) -> bool
source§impl<M, __M> StrippedPartialOrd<Object<__M>> for Object<M>
impl<M, __M> StrippedPartialOrd<Object<__M>> for Object<M>
impl<M> Eq for Object<M>where
M: Eq,
impl<M> StrippedEq for Object<M>
Auto Trait Implementations§
impl<M> RefUnwindSafe for Object<M>where
M: RefUnwindSafe,
impl<M> Send for Object<M>where
M: Send,
impl<M> Sync for Object<M>where
M: Sync,
impl<M> Unpin for Object<M>where
M: Unpin,
impl<M> UnwindSafe for Object<M>where
M: UnwindSafe,
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
fn equivalent(&self, key: &K) -> bool
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.