Skip to main content

Object

Enum Object 

Source
pub enum Object<T = IriBuf, B = BlankIdBuf> {
    Value(Value<T>),
    Node(Box<Node<T, B>>),
    List(List<T, B>),
}
Expand description

Object.

JSON-LD connects together multiple kinds of data objects. Objects may be nodes, values or lists of objects.

You can get an Object by expanding a JSON-LD document using the expansion algorithm or by converting an already expanded JSON document using TryFromJson.

Variants§

§

Value(Value<T>)

Value object.

§

Node(Box<Node<T, B>>)

Node object.

§

List(List<T, B>)

List object.

Implementations§

Source§

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

Source

pub fn null() -> Self

Creates a null value object.

Source

pub fn node(n: Node<T, B>) -> Self

Creates a new node object from a node.

Source

pub fn id(&self) -> Option<&Id<T, B>>

Identifier of the object, if it is a node object.

Source

pub fn identify_all_with<V: VocabularyMut<Iri = T, BlankId = B>, G: LocalGenerator>( &mut self, vocabulary: &mut V, generator: &mut G, ) -> Result<(), GeneratedIdError>
where T: Eq + Hash, B: Eq + Hash,

Assigns an identifier to every node included in this object using the given generator.

§Errors

Returns an error when the generator runs out of identifiers.

Source

pub fn identify_all<G: LocalGenerator>( &mut self, generator: &mut G, ) -> Result<(), GeneratedIdError>
where T: Eq + Hash, B: Eq + Hash, (): Vocabulary<Iri = T, BlankId = B>,

Use the given generator to assign an identifier to all nodes that don’t have one.

§Errors

Returns an error when the generator runs out of identifiers.

Source

pub fn canonicalize_with(&mut self, buffer: &mut Buffer)

Puts every literal of the object into canonical form, using the given buffer to render numbers.

Source

pub fn canonicalize(&mut self)

Puts every literal of the object into canonical form.

Source

pub fn types(&self) -> Types<'_, T, B> ⓘ

Returns an iterator over the types of the object.

Source

pub fn as_iri(&self) -> Option<&T>

Identifier of the object as an IRI.

If the object is a node identified by an IRI, returns this IRI. Returns None otherwise.

Source

pub fn is_value(&self) -> bool

Tests if the object is a value.

Source

pub fn as_value(&self) -> Option<&Value<T>>

Returns this object as a value, if it is one.

Source

pub fn as_value_mut(&mut self) -> Option<&mut Value<T>>

Returns this object as a mutable value, if it is one.

Source

pub fn into_value(self) -> Option<Value<T>>

Converts this object into a value, if it is one.

Source

pub fn is_node(&self) -> bool

Tests if the object is a node.

Source

pub fn as_node(&self) -> Option<&Node<T, B>>

Returns this object as a node, if it is one.

Source

pub fn as_node_mut(&mut self) -> Option<&mut Node<T, B>>

Returns this object as a mutable node, if it is one.

Source

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

Converts this object into a node, if it is one.

Source

pub fn is_graph(&self) -> bool

Tests if the object is a graph object (a node with a @graph field).

Source

pub fn is_list(&self) -> bool

Tests if the object is a list.

Source

pub fn as_list(&self) -> Option<&List<T, B>>

Returns this object as a list, if it is one.

Source

pub fn as_list_mut(&mut self) -> Option<&mut List<T, B>>

Returns this object as a mutable list, if it is one.

Source

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

Converts this object into a list, if it is one.

Source

pub fn as_str(&self) -> Option<&str>
where T: AsRef<str>, B: AsRef<str>,

Returns the object as a string.

If the object is a value holding a string, returns that string. If the object is a node with an identifier, returns the identifier as a string. Returns None otherwise.

Source

pub fn as_bool(&self) -> Option<bool>

Returns the object as a boolean, if it is a value holding one.

Source

pub fn as_number(&self) -> Option<&Number>

Returns the object as a number, if it is a value holding one.

Source

pub fn language(&self) -> Option<&LenientLangTag>

Returns the associated language, if the object is a language-tagged value.

Source

pub fn traverse(&self) -> Traverse<'_, T, B> ⓘ

Returns an iterator over all fragments of this object, including the object itself.

Fragments include:

  • objects
  • key-value pairs,
  • keys
  • values
Source

pub fn equivalent(&self, other: &Self) -> bool
where T: Eq + Hash, B: Eq + Hash,

Equivalence operator.

Equivalence differs from equality for anonymous objects: list objects and anonymous node objects stand for implicit, unlabeled blank nodes, so they are never equivalent to anything.

Source

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

Returns an iterator over the entries of the JSON representation of the object.

Source

pub fn map_ids<U, C>( self, map_iri: impl FnMut(T) -> U, map_id: impl FnMut(Id<T, B>) -> Id<U, C>, ) -> Object<U, C>
where U: Eq + Hash, C: Eq + Hash,

Rewrites every IRI and identifier of the object (recursively) with the given functions.

Trait Implementations§

Source§

impl<T, B> Any<T, B> for Object<T, B>

Source§

fn as_ref(&self) -> Ref<'_, T, B>

Borrows the object as a value, node or list reference.
Source§

fn id(&self) -> Option<&Id<T, B>>

Returns the identifier (@id) of the object, if it is a node object with one.
Source§

fn language<'a>(&'a self) -> Option<&'a LenientLangTag>
where T: 'a, B: 'a,

Returns the language tag of this value, if it carries one.
Source§

fn is_value(&self) -> bool

Checks whether the object is a value object.
Source§

fn is_node(&self) -> bool

Checks whether the object is a node object.
Source§

fn is_graph(&self) -> bool

Checks whether the object is a graph object (a node object with a @graph entry).
Source§

fn is_list(&self) -> bool

Checks whether the object is a list object.
Source§

impl<T: Clone, B: Clone> Clone for Object<T, B>

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, B: Debug> Debug for Object<T, B>

Source§

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

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

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

Source§

impl<T, B> From<Node<T, B>> for Object<T, B>

Source§

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

Converts to this type from the input type.
Source§

impl<T, B> From<Value<T>> for Object<T, B>

Source§

fn from(value: Value<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash, B: Hash> Hash for Object<T, B>

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, B, N: Vocabulary<Iri = T, BlankId = B>> IntoJsonWithContext<N> for Object<T, B>

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, B, I: Interpretation> LinkedData<I> for Object<T, B>

Source§

fn visit<S>(&self, visitor: S) -> Result<S::Ok, S::Error>
where S: Visitor<I>,

Visit the RDF dataset represented by this type.
Source§

impl<T, B, I: Interpretation> LinkedDataGraph<I> for Object<T, B>

Source§

fn visit_graph<S>(&self, visitor: S) -> Result<S::Ok, S::Error>
where S: GraphVisitor<I>,

Visits the subjects of the graph represented by this value.
Source§

impl<T, B, I: Interpretation> LinkedDataPredicateObjects<I> for Object<T, B>

Source§

fn visit_objects<S>(&self, visitor: S) -> Result<S::Ok, S::Error>

Visits the objects this predicate points at.
Source§

impl<T, B, I: Interpretation> LinkedDataResource<I> for Object<T, B>

Source§

fn interpretation( &self, interpretation: &mut I, ) -> ResourceInterpretation<'_, I>

Returns the interpretation of this resource, inserting it into interpretation if required.
Source§

fn lexical_representation<'a>( &'a self, interpretation: &'a mut I, ) -> Option<CowRdfTerm<'a>>

Returns the lexical term representing this resource, if any.
Source§

fn reference_interpretation( &self, interpretation: &mut I, ) -> ResourceInterpretation<'_, I>

Returns the interpretation to use when this resource appears as a reference rather than as a subject with properties.
Source§

impl<T, B, I: Interpretation> LinkedDataSubject<I> for Object<T, B>

Source§

fn visit_subject<S>(&self, visitor: S) -> Result<S::Ok, S::Error>
where S: SubjectVisitor<I>,

Visits the properties of the subject represented by this value.
Source§

impl<T: Eq + Hash, B: Eq + Hash> MappedEq for Object<T, B>

Source§

type BlankId = B

Blank node identifier type the renaming applies to.
Source§

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

Structural equality with mapped blank identifiers. Read more
Source§

impl<T, B> PartialEq for Object<T, B>
where T: Eq + Hash, B: Eq + Hash,

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, B> Relabel<T, B> for Object<T, B>

Source§

fn relabel_with<N: VocabularyMut<Iri = T, BlankId = B>, G: LocalGenerator>( &mut self, vocabulary: &mut N, generator: &mut G, relabeling: &mut HashMap<B, ValidId<T, B>>, ) -> Result<(), GeneratedIdError>
where T: Clone + Eq + Hash, B: Clone + Eq + Hash,

Relabels every blank node, recording the mapping so shared nodes keep the same new identifier. Read more
Source§

fn relabel<G: LocalGenerator>( &mut self, generator: &mut G, relabeling: &mut HashMap<B, ValidId<T, B>>, ) -> Result<(), GeneratedIdError>
where T: Clone + Eq + Hash, B: Clone + Eq + Hash, (): Vocabulary<Iri = T, BlankId = B>,

Relabels every blank node, recording the mapping. Read more
Source§

impl<T, B> TryFrom<Object<T, B>> for Node<T, B>

Source§

type Error = Object<T, B>

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

fn try_from(obj: Object<T, B>) -> Result<Node<T, B>, Object<T, B>>

Performs the conversion.
Source§

impl<T: Eq + Hash, B: Eq + Hash> TryFromJson<T, B> for Object<T, B>

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: Eq + Hash, B: Eq + Hash> TryFromJsonObject<T, B> for Object<T, B>

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, B> Freeze for Object<T, B>
where Value<T>: Freeze, Box<Node<T, B>>: Freeze, List<T, B>: Freeze,

§

impl<T, B> RefUnwindSafe for Object<T, B>

§

impl<T, B> Send for Object<T, B>
where Value<T>: Send, Box<Node<T, B>>: Send, List<T, B>: Send,

§

impl<T, B> Sync for Object<T, B>
where Value<T>: Sync, Box<Node<T, B>>: Sync, List<T, B>: Sync,

§

impl<T, B> Unpin for Object<T, B>
where Value<T>: Unpin, Box<Node<T, B>>: Unpin, List<T, B>: Unpin,

§

impl<T, B> UnsafeUnpin for Object<T, B>
where Value<T>: UnsafeUnpin, Box<Node<T, B>>: UnsafeUnpin, List<T, B>: UnsafeUnpin,

§

impl<T, B> UnwindSafe for Object<T, B>
where Value<T>: UnwindSafe, Box<Node<T, B>>: UnwindSafe, List<T, B>: 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> 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<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