Struct json_ld_syntax::Object

source ·
pub struct Object { /* private fields */ }
Expand description

Object.

Implementations§

source§

impl Object

source

pub fn new() -> Object

source

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

source

pub fn capacity(&self) -> usize

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn get_fragment(&self, index: usize) -> Result<FragmentRef<'_>, usize>

source

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

source

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

source

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

source

pub fn iter_mapped<'m>( &self, code_map: &'m CodeMap, offset: usize ) -> IterMapped<'_, 'm>

source

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

Checks if this object contains the given key.

Runs in O(1) (average).

source

pub fn get<Q>(&self, key: &Q) -> Values<'_>
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<'_>
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<&Value>, Duplicate<&Entry>>
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 Value>, Duplicate<&Entry>>
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<'_>
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>, Duplicate<&Entry>>
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<'_>
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_entries_with_index<Q>(&self, key: &Q) -> EntriesWithIndex<'_>
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_or_insert_with<Q>( &mut self, key: &Q, f: impl FnOnce() -> Value ) -> &Value
where Q: Hash + Equivalent<SmallString<[u8; 16]>> + ToOwned + ?Sized, <Q as ToOwned>::Owned: Into<SmallString<[u8; 16]>>,

Returns the (first) value associated to key, or insert a key-value entry where value is returned by the given function f.

source

pub fn get_mut_or_insert_with<Q>( &mut self, key: &Q, f: impl FnOnce() -> Value ) -> &mut Value
where Q: Hash + Equivalent<SmallString<[u8; 16]>> + ToOwned + ?Sized, <Q as ToOwned>::Owned: Into<SmallString<[u8; 16]>>,

Returns a mutable reference to the (first) value associated to key, or insert a key-value entry where value is returned by the given function f.

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 get_mapped_entries<'m, Q>( &self, code_map: &'m CodeMap, offset: usize, key: &Q ) -> MappedEntries<'_, 'm>
where Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,

Returns an iterator over the mapped entries matching the given key.

Runs in O(n) (average). O(1) to find the entry, O(n) to compute the entry fragment offset.

source

pub fn get_unique_mapped_entry<Q>( &self, code_map: &CodeMap, offset: usize, key: &Q ) -> Result<Option<Mapped<Entry<Mapped<&SmallString<[u8; 16]>>, Mapped<&Value>>>>, Duplicate<Mapped<Entry<Mapped<&SmallString<[u8; 16]>>, Mapped<&Value>>>>>
where Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,

Returns the unique mapped entry matching the given key.

Runs in O(n) (average). O(1) to find the entry, O(n) to compute the entry fragment offset.

source

pub fn get_mapped_entries_with_index<'m, Q>( &self, code_map: &'m CodeMap, offset: usize, key: &Q ) -> MappedEntriesWithIndex<'_, 'm>
where Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,

Returns an iterator over the mapped entries matching the given key, with their index.

Runs in O(n) (average). O(1) to find the entry, O(n) to compute the entry fragment offset.

source

pub fn get_unique_mapped_entry_with_index<Q>( &self, code_map: &CodeMap, offset: usize, key: &Q ) -> Result<Option<(usize, Mapped<Entry<Mapped<&SmallString<[u8; 16]>>, Mapped<&Value>>>)>, Duplicate<(usize, Mapped<Entry<Mapped<&SmallString<[u8; 16]>>, Mapped<&Value>>>)>>
where Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,

Returns the unique mapped entry matching the given key, with its index.

Runs in O(n) (average). O(1) to find the entry, O(n) to compute the entry fragment offset.

source

pub fn get_mapped<'m, Q>( &self, code_map: &'m CodeMap, offset: usize, key: &Q ) -> MappedValues<'_, 'm>
where Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,

Returns an iterator over the mapped values matching the given key.

Runs in O(n) (average). O(1) to find the entry, O(n) to compute the entry fragment offset.

source

pub fn get_unique_mapped<Q>( &self, code_map: &CodeMap, offset: usize, key: &Q ) -> Result<Option<Mapped<&Value>>, Duplicate<Mapped<&Value>>>
where Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,

Returns the unique mapped values matching the given key.

Runs in O(n) (average). O(1) to find the entry, O(n) to compute the entry fragment offset.

source

pub fn get_mapped_with_index<'m, Q>( &self, code_map: &'m CodeMap, offset: usize, key: &Q ) -> MappedValuesWithIndex<'_, 'm>
where Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,

Returns an iterator over the mapped values matching the given key, with their index.

Runs in O(n) (average). O(1) to find the entry, O(n) to compute the entry fragment offset.

source

pub fn get_unique_mapped_with_index<Q>( &self, code_map: &CodeMap, offset: usize, key: &Q ) -> Result<Option<(usize, Mapped<&Value>)>, Duplicate<(usize, Mapped<&Value>)>>
where Q: Hash + Equivalent<SmallString<[u8; 16]>> + ?Sized,

Returns the unique mapped values matching the given key, with its index.

Runs in O(n) (average). O(1) to find the entry, O(n) to compute the entry fragment offset.

source

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

source

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

source

pub fn push(&mut self, key: SmallString<[u8; 16]>, 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).

source

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

source

pub fn push_front(&mut self, key: SmallString<[u8; 16]>, 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).

source

pub fn push_entry_front(&mut self, entry: Entry) -> bool

source

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

Removes the entry at the given index.

source

pub fn insert( &mut self, key: SmallString<[u8; 16]>, 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.

source

pub fn insert_front( &mut self, key: SmallString<[u8; 16]>, 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.

source

pub fn remove<'q, Q>(&mut self, key: &'q Q) -> RemovedEntries<'_, 'q, 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>, Duplicate<Entry>>
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 sort(&mut self)

Sort the entries by key name.

Entries with the same key are sorted by value.

Trait Implementations§

source§

impl Clone for Object

source§

fn clone(&self) -> Object

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 Debug for Object

source§

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

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

impl Default for Object

source§

fn default() -> Object

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

impl Extend<(SmallString<[u8; 16]>, Value)> for Object

source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = (SmallString<[u8; 16]>, Value)>,

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 Extend<Entry> for Object

source§

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

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 From<Object> for Value

source§

fn from(o: Object) -> Value

Converts to this type from the input type.
source§

impl From<Vec<Entry>> for Object

source§

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

Converts to this type from the input type.
source§

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

source§

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

Creates a value from an iterator. Read more
source§

impl FromIterator<Entry> for Object

source§

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

Creates a value from an iterator. Read more
source§

impl Hash for Object

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

§

type Item = &'a Entry

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, Entry>

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

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

Creates an iterator from a value. Read more
source§

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

§

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

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a>

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

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

Creates an iterator from a value. Read more
source§

impl IntoIterator for Object

§

type Item = Entry

The type of the elements being iterated over.
§

type IntoIter = IntoIter<Entry>

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

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

Creates an iterator from a value. Read more
source§

impl Ord for Object

source§

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

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

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

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

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

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

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

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

impl PartialEq for Object

source§

fn eq(&self, other: &Object) -> 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 PartialOrd for Object

source§

fn partial_cmp(&self, other: &Object) -> 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 PrintWithSize for Object

source§

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

source§

impl UnorderedPartialEq for Object

source§

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

source§

impl Eq for Object

source§

impl UnorderedEq for Object

Auto Trait Implementations§

§

impl Freeze for Object

§

impl RefUnwindSafe for Object

§

impl Send for Object

§

impl Sync for Object

§

impl Unpin for Object

§

impl UnwindSafe for Object

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> 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 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> BorrowStripped for T

source§

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

source§

impl<T> BorrowUnordered for T

source§

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

source§

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

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

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

source§

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

source§

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

Checks if this value is equivalent to the given key. Read more
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, C> FromWithContext<T, C> for T

source§

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

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

source§

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

source§

impl<T> ToOwned for T
where 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 T
where 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 T
where 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 T
where 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 T
where 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 T
where T: ?Sized,

source§

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

source§

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