Skip to main content

Indexed

Struct Indexed 

Source
pub struct Indexed<T> { /* private fields */ }
Expand description

Indexed objects.

Nodes and value objects may be indexed by a string in JSON-LD. This type is a wrapper around any kind of indexable data.

It is a pointer type that Deref into the underlying value.

Implementations§

Source§

impl<T> Indexed<T>

Source

pub fn none(value: T) -> Self

Creates a non-indexed value, without metadata.

Source

pub fn new(value: T, index: Option<String>) -> Self

Create a new (maybe) indexed value.

Source

pub fn inner(&self) -> &T

Get a reference to the inner value.

Source

pub fn inner_mut(&mut self) -> &mut T

Mutably borrows the indexed value.

Source

pub fn into_inner(self) -> T

Drops the index and returns the underlying value.

Source

pub fn index(&self) -> Option<&str>

Returns the @index of the value, if it has one.

Source

pub fn set_index(&mut self, index: Option<String>)

Sets the @index of the value, or removes it when given None.

Source

pub fn into_parts(self) -> (T, Option<String>)

Consumes the indexed value, returning the inner value and its @index.

Source

pub fn map_inner<U, F>(self, f: F) -> Indexed<U>
where F: FnOnce(T) -> U,

Cast the inner value.

Source

pub fn cast<U: From<T>>(self) -> Indexed<U>

Cast the inner value.

Source

pub fn try_cast<U: TryFrom<T>>(self) -> Result<Indexed<U>, Indexed<U::Error>>

Try to cast the inner value.

§Errors

Returns the index and the conversion error when the inner value does not convert.

Source§

impl<T, B> Indexed<Node<T, B>>

Source

pub fn entries(&self) -> IndexedEntries<'_, T, B> ⓘ

Returns an iterator over the entries of the JSON representation of the node, including its @index entry if any.

Source§

impl<T: Eq + Hash, B: Eq + Hash> Indexed<Node<T, B>>

Source

pub fn equivalent(&self, other: &Self) -> bool

Checks whether the two indexed nodes are equivalent: same @index and equivalent inner nodes.

Source§

impl<T: Eq + Hash, B: Eq + Hash> Indexed<Object<T, B>>

Source

pub fn equivalent(&self, other: &Self) -> bool

Checks whether the two indexed objects are equivalent: same @index and equivalent inner objects.

Source§

impl<T, B> Indexed<Object<T, B>>

Source

pub fn into_indexed_node(self) -> Option<Indexed<Node<T, B>>>

Converts this indexed object into an indexed node, if it is one.

Source

pub fn into_indexed_value(self) -> Option<Indexed<Value<T>>>

Converts this indexed object into an indexed value, if it is one.

Source

pub fn into_indexed_list(self) -> Option<Indexed<List<T, B>>>

Converts this indexed object into an indexed list, if it is one.

Source

pub fn into_unnamed_graph(self) -> Result<Graph<T, B>, Self>

Try to convert this object into an unnamed graph.

§Errors

Returns self unchanged when the object is not a graph object, or is a named graph.

Source

pub fn entries(&self) -> IndexedEntries<'_, T, B> ⓘ

Returns an iterator over the entries of the JSON representation of the object, including its @index entry if any.

Trait Implementations§

Source§

impl<T> AsMut<T> for Indexed<T>

Source§

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

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T> AsRef<T> for Indexed<T>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Clone> Clone for Indexed<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Indexed<T>

Source§

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

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

impl<T> Deref for Indexed<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T> DerefMut for Indexed<T>

Source§

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

Mutably dereferences the value.
Source§

impl<T: Eq> Eq for Indexed<T>

Source§

impl<T: Hash + Eq, B: Hash + Eq> Extend<Indexed<Object<T, B>>> for ExpandedDocument<T, B>

Source§

fn extend<I: IntoIterator<Item = IndexedObject<T, B>>>(&mut self, iter: I)

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

fn extend_one(&mut self, item: T)

🔬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<T: Eq + Hash, B: Eq + Hash> From<Indexed<Node<T, B>>> for ExpandedDocument<T, B>

Source§

fn from(value: Indexed<Node<T, B>>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<T> for Indexed<T>

Source§

fn from(value: T) -> Indexed<T>

Converts to this type from the input type.
Source§

impl<T: Hash + Eq, B: Hash + Eq> FromIterator<Indexed<Object<T, B>>> for ExpandedDocument<T, B>

Source§

fn from_iter<I: IntoIterator<Item = IndexedObject<T, B>>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: Hash> Hash for Indexed<T>

Source§

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

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<T: IntoJsonWithContext<N>, N> IntoJsonWithContext<N> for Indexed<T>

Source§

fn into_json_with(self, vocabulary: &N) -> Value

Converts this value into JSON, resolving the identifiers it holds against the given vocabulary. Read more
Source§

impl<T: MappedEq> MappedEq for Indexed<T>

Source§

type BlankId = <T as MappedEq>::BlankId

Blank node identifier type the renaming applies to.
Source§

fn mapped_eq<'a, 'b, F: Clone + Fn(&'a Self::BlankId) -> &'b Self::BlankId>( &'a self, other: &Self, f: F, ) -> bool
where Self::BlankId: 'a + 'b,

Structural equality with mapped blank identifiers. Read more
Source§

impl<T: Ord> Ord for Indexed<T>

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl<T: PartialEq> PartialEq for Indexed<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T: PartialOrd> PartialOrd for Indexed<T>

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T, B, N: Vocabulary<Iri = T, BlankId = B>> PrecomputeSizeWithContext<N> for Indexed<Object<T, B>>

Source§

fn contextual_pre_compute_size( &self, vocabulary: &N, options: &Options, sizes: &mut Vec<Size>, ) -> Size

Computes the printed size of this value against context.
Source§

impl<T, B, N: Vocabulary<Iri = T, BlankId = B>> PrecomputeSizeWithContext<N> for Indexed<Node<T, B>>

Source§

fn contextual_pre_compute_size( &self, vocabulary: &N, options: &Options, sizes: &mut Vec<Size>, ) -> Size

Computes the printed size of this value against context.
Source§

impl<T, B, N: Vocabulary<Iri = T, BlankId = B>> PrintWithSizeAndContext<N> for Indexed<Object<T, B>>

Source§

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

Writes the value to f against context, taking its layout from sizes[*index]. Read more
Source§

impl<T, B, N: Vocabulary<Iri = T, BlankId = B>> PrintWithSizeAndContext<N> for Indexed<Node<T, B>>

Source§

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

Writes the value to f against context, taking its layout from sizes[*index]. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for Indexed<T>

Source§

impl<T, B, O: TryFromJsonObject<T, B>> TryFromJson<T, B> for Indexed<O>

Source§

fn try_from_json_in( vocabulary: &mut impl VocabularyMut<Iri = T, BlankId = B>, value: Value, ) -> Result<Self, InvalidExpandedJson>

Builds this fragment from a JSON value, interning terms in the given vocabulary. Read more
Source§

impl<T, B, O: TryFromJsonObject<T, B>> TryFromJsonObject<T, B> for Indexed<O>

Source§

fn try_from_json_object_in( vocabulary: &mut impl VocabularyMut<Iri = T, BlankId = B>, object: Object, ) -> Result<Self, InvalidExpandedJson>

Builds this fragment from a JSON object, interning terms in the given vocabulary. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Indexed<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Indexed<T>
where T: RefUnwindSafe,

§

impl<T> Send for Indexed<T>
where T: Send,

§

impl<T> Sync for Indexed<T>
where T: Sync,

§

impl<T> Unpin for Indexed<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Indexed<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Indexed<T>
where T: UnwindSafe,

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

Source§

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

Views this value as an Unordered reference.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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

Checks if self is equivalent to key.
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<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<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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U, C> TryFromWithContext<U, C> for T
where U: IntoWithContext<T, C>,

Source§

type Error = !

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

Source§

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

Source§

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>
where T: Sized,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more