Struct json_ld_core::Indexed

source ·
pub struct Indexed<T, M> { /* 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, M> Indexed<T, M>

source

pub fn new(value: T, index: Option<Entry<String, M>>) -> Indexed<T, M>

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

source

pub fn into_inner(self) -> T

Drop the index and return the underlying value.

source

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

Get the index, if any.

source

pub fn index_entry(&self) -> Option<&Entry<String, M>>

Get the index entry, if any.

source

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

Set the value index.

source

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

Turn this indexed value into its components: inner value and index.

source

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

Cast the inner value.

source

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

Cast the inner value.

source

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

Try to cast the inner value.

source§

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

source

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

source§

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

source

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

source§

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

source

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

source§

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

source

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

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

source

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

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

source

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

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

source

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

Try to convert this object into an unnamed graph.

source

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

Trait Implementations§

source§

impl<T, M> AsMut<T> for Indexed<T, M>

source§

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

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

impl<T, M> AsRef<T> for Indexed<T, M>

source§

fn as_ref(&self) -> &T

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

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

source§

fn clone(&self) -> Indexed<T, 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<T: Debug, M: Debug> Debug for Indexed<T, M>

source§

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

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

impl<T, M> Deref for Indexed<T, M>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &T

Dereferences the value.
source§

impl<T, M> DerefMut for Indexed<T, M>

source§

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

Mutably dereferences the value.
source§

impl<T, M> From<T> for Indexed<T, M>

source§

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

Converts to this type from the input type.
source§

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

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

source§

fn into_json_meta_with(self, meta: M, vocabulary: &N) -> Meta<Value<M>, M>

source§

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

§

type BlankId = <T as MappedEq<T>>::BlankId

source§

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

Structural equality with mapped blank identifiers. Read more
source§

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

source§

fn cmp(&self, other: &Indexed<T, 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<T: PartialEq, M: PartialEq> PartialEq<Indexed<T, M>> for Indexed<T, M>

source§

fn eq(&self, other: &Indexed<T, 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<T: PartialOrd, M: PartialOrd> PartialOrd<Indexed<T, M>> for Indexed<T, M>

source§

fn partial_cmp(&self, other: &Indexed<T, 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<T, B, M, N: Vocabulary<Iri = T, BlankId = B>> PrecomputeSizeWithContext<N> for Indexed<Node<T, B, M>, M>

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<T: StrippedHash, M> StrippedHash for Indexed<T, M>

source§

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

source§

impl<T: StrippedPartialEq<__T>, M, __T, __M> StrippedPartialEq<Indexed<__T, __M>> for Indexed<T, M>

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<T: StrippedEq, M> StrippedEq for Indexed<T, M>

source§

impl<T, M> StructuralEq for Indexed<T, M>

source§

impl<T, M> StructuralPartialEq for Indexed<T, M>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<T, M> UnwindSafe for Indexed<T, M>where M: UnwindSafe, T: 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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · 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

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

const: unstable · source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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> 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> ToOwned for T

§

type Owned = T

source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
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>