Enum json_ld_core::object::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: Vocabulary<Iri = T, BlankId = B>, G: Generator<V>>( &mut self, vocabulary: &mut V, generator: &mut G, )
where T: Eq + Hash, B: Eq + Hash,

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

source

pub fn identify_all<G: Generator>(&mut self, generator: &mut G)
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.

source

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

Puts this object literals into canonical form using the given buffer.

The buffer is used to compute the canonical form of numbers.

source

pub fn canonicalize(&mut self)

Puts this object literals 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 as 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>,

Get the object as a string.

If the object is a value that is a string, returns this string. If the object is a node that is identified, returns the identifier as a string. Returns None otherwise.

source

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

Get the value as a boolean, if it is.

source

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

Get the value as a number, if it is.

source

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

If the object is a language-tagged value, Return its associated language.

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 is different from equality for anonymous objects: List objects and anonymous node objects have an implicit unlabeled blank nodes and thus never equivalent.

source

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

Returns an iterator over the entries of 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,

Map the identifiers present in this object (recursively).

Trait Implementations§

source§

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

source§

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

source§

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

source§

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

source§

fn is_value(&self) -> bool

source§

fn is_node(&self) -> bool

source§

fn is_graph(&self) -> bool

source§

fn is_list(&self) -> bool

source§

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

source§

fn clone(&self) -> Object<T, B>

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

source§

impl<T, B, V, I: Interpretation> LinkedData<I, V> for Object<T, B>

source§

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

Visit the RDF dataset represented by this type.
source§

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

source§

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

source§

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

source§

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

source§

impl<T, B, V: Vocabulary<Iri = T>, I: Interpretation> LinkedDataResource<I, V> for Object<T, B>
where T: LinkedDataResource<I, V>, B: LinkedDataResource<I, V>,

source§

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

source§

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

source§

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

source§

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

source§

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

§

type BlankId = B

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

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

source§

fn relabel_with<N: Vocabulary<Iri = T, BlankId = B>, G: Generator<N>>( &mut self, vocabulary: &mut N, generator: &mut G, relabeling: &mut HashMap<B, Subject<T, B>>, )
where T: Clone + Eq + Hash, B: Clone + Eq + Hash,

source§

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

§

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>

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>

source§

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

Auto Trait Implementations§

§

impl<T, B> Freeze for Object<T, B>
where T: Freeze,

§

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

§

impl<T, B> Send for Object<T, B>
where T: Send, B: Send,

§

impl<T, B> Sync for Object<T, B>
where T: Sync, B: Sync,

§

impl<T, B> Unpin for Object<T, B>
where T: Unpin,

§

impl<T, B> UnwindSafe for Object<T, B>
where T: UnwindSafe, 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> 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<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

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

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<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, 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> Same for T

§

type Output = T

Should always be Self
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>