Struct json_ld_syntax::Object

source ·
pub struct Object<M = ()> { /* private fields */ }
Expand description

Object.

Implementations§

source§

impl<M> Object<M>

source

pub fn new() -> Object<M>

source

pub fn from_vec(entries: Vec<Entry<M>, Global>) -> Object<M>

source

pub fn capacity(&self) -> usize

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn entries(&self) -> &[Entry<M>]

source

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

source

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

source

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).

source

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).

source

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).

source

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).

source

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).

source

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).

source

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).

source

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).

source

pub fn index_of<Q>(&self, key: &Q) -> Option<usize>where Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,

source

pub fn redundant_index_of<Q>(&self, key: &Q) -> Option<usize>where Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,

source

pub fn indexes_of<Q>(&self, key: &Q) -> Indexes<'_> where Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,

source

pub fn first(&self) -> Option<&Entry<M>>

source

pub fn last(&self) -> Option<&Entry<M>>

source

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).

source

pub fn push_entry(&mut self, entry: Entry<M>) -> bool

source

pub fn remove_at(&mut self, index: usize) -> Option<Entry<M>>

Removes the entry at the given index.

source

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.

source

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).

source

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).

source

pub fn map_metadata<N>(self, f: impl FnMut(M) -> N) -> Object<N>

Recursively maps the metadata inside the object.

source

pub fn try_map_metadata<N, E>( self, f: impl FnMut(M) -> Result<N, E> ) -> Result<Object<N>, E>

Tries to recursively maps the metadata inside the object.

source

pub fn sort(&mut self)

Sort the entries by key name.

Entries with the same key are sorted by value.

Trait Implementations§

source§

impl<M> Clone for Object<M>where M: Clone,

source§

fn clone(&self) -> Object<M>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<M> Debug for Object<M>where M: Debug,

source§

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

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

impl<M> Default for Object<M>

source§

fn default() -> Object<M>

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

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

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<M> Extend<Entry<M>> for Object<M>

source§

fn extend<I>(&mut self, iter: I)where I: IntoIterator<Item = Entry<M>>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<M> From<Object<M>> for Value<M>

source§

fn from(o: Object<M>) -> Value<M>

Converts to this type from the input type.
source§

impl<M> From<Vec<Entry<M>, Global>> for Object<M>

source§

fn from(entries: Vec<Entry<M>, Global>) -> Object<M>

Converts to this type from the input type.
source§

impl<M> FromIterator<(Meta<SmallString<[u8; 16]>, M>, Meta<Value<M>, M>)> for Object<M>

source§

fn from_iter<I>(iter: I) -> Object<M>where I: IntoIterator<Item = (Meta<SmallString<[u8; 16]>, M>, Meta<Value<M>, M>)>,

Creates a value from an iterator. Read more
source§

impl<M> FromIterator<Entry<M>> for Object<M>

source§

fn from_iter<I>(iter: I) -> Object<M>where I: IntoIterator<Item = Entry<M>>,

Creates a value from an iterator. Read more
source§

impl<M> Hash for Object<M>where M: Hash,

source§

fn hash<H>(&self, state: &mut H)where H: Hasher,

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<'a, M> IntoIterator for &'a Object<M>

§

type Item = &'a Entry<M>

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, Entry<M>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <&'a Object<M> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, M> IntoIterator for &'a mut Object<M>

§

type Item = (&'a Meta<SmallString<[u8; 16]>, M>, &'a mut Meta<Value<M>, M>)

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a, M>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <&'a mut Object<M> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<M> IntoIterator for Object<M>

§

type Item = Entry<M>

The type of the elements being iterated over.
§

type IntoIter = IntoIter<Entry<M>, Global>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <Object<M> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<M> Ord for Object<M>where M: Ord,

source§

fn cmp(&self, other: &Object<M>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

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

impl<M> PartialEq<Object<M>> for Object<M>where M: PartialEq<M>,

source§

fn eq(&self, other: &Object<M>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<M> PartialOrd<Object<M>> for Object<M>where M: PartialOrd<M>,

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

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

impl<M> PrintWithSize for Object<M>

source§

fn fmt_with_size( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, sizes: &[Size], index: &mut usize ) -> Result<(), Error>

source§

impl<M> StrippedHash for Object<M>

source§

fn stripped_hash<H>(&self, state: &mut H)where H: Hasher,

source§

impl<M> StrippedOrd for Object<M>

source§

fn stripped_cmp(&self, other: &Object<M>) -> Ordering

source§

impl<M, __M> StrippedPartialEq<Object<__M>> for Object<M>

source§

fn stripped_eq(&self, other: &Object<__M>) -> bool

source§

impl<M, __M> StrippedPartialOrd<Object<__M>> for Object<M>

source§

impl<M> UnorderedPartialEq for Object<M>where M: PartialEq<M>,

source§

fn unordered_eq(&self, other: &Object<M>) -> bool

source§

impl<M> Eq for Object<M>where M: Eq,

source§

impl<M> StrippedEq for Object<M>

source§

impl<M> UnorderedEq for Object<M>where M: Eq,

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<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> At for T

source§

fn at<M>(self, metadata: M) -> Meta<T, M>

Wraps self inside a Meta<Self, M> using the given metadata. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowStripped for T

source§

fn stripped(&self) -> &Stripped<T>

source§

impl<T> BorrowUnordered for T

source§

fn unordered(&self) -> &Unordered<T>

§

impl<T> CallHasher for Twhere T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64where H: Hash + ?Sized, B: BuildHasher,

source§

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

source§

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

source§

impl<Q, K> Equivalent<K> for Qwhere 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, C> FromWithContext<T, C> for T

source§

fn from_with(value: T, _context: &C) -> T

source§

impl<T, U> Into<U> for Twhere 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, U, C> IntoWithContext<U, C> for Twhere U: FromWithContext<T, C>,

source§

fn into_with(self, context: &C) -> U

source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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, C> TryFromWithContext<U, C> for Twhere U: IntoWithContext<T, C>,

§

type Error = Infallible

source§

fn try_from_with( value: U, context: &C ) -> Result<T, <T as TryFromWithContext<U, C>>::Error>

source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.
source§

impl<T, U, C> TryIntoWithContext<U, C> for Twhere U: TryFromWithContext<T, C>,

§

type Error = <U as TryFromWithContext<T, C>>::Error

source§

fn try_into_with( self, context: &C ) -> Result<U, <T as TryIntoWithContext<U, C>>::Error>

source§

impl<T> WithContext for Twhere T: ?Sized,

source§

fn with<C>(&self, context: C) -> Contextual<&T, C>

source§

fn into_with<C>(self, context: C) -> Contextual<T, C>