Enum json_ld_core::object::Object
source · pub enum Object<T = IriBuf, B = BlankIdBuf, M = ()> {
Value(Value<T, M>),
Node(Box<Node<T, B, M>>),
List(List<T, B, M>),
}
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, M>)
Value object.
Node(Box<Node<T, B, M>>)
Node object.
List(List<T, B, M>)
List object.
Implementations§
source§impl<T, B, M> Object<T, B, M>
impl<T, B, M> Object<T, B, M>
sourcepub fn id(&self) -> Option<&Meta<Id<T, B>, M>>
pub fn id(&self) -> Option<&Meta<Id<T, B>, M>>
Identifier of the object, if it is a node object.
sourcepub fn identify_all_with<V: Vocabulary<Iri = T, BlankId = B>, G: Generator<V, M>>(
&mut self,
vocabulary: &mut V,
generator: &mut G
)where
M: Clone,
T: Eq + Hash,
B: Eq + Hash,
pub fn identify_all_with<V: Vocabulary<Iri = T, BlankId = B>, G: Generator<V, M>>( &mut self, vocabulary: &mut V, generator: &mut G )where M: Clone, T: Eq + Hash, B: Eq + Hash,
Assigns an identifier to every node included in this object using the given generator
.
sourcepub fn identify_all<G: Generator<(), M>>(&mut self, generator: &mut G)where
M: Clone,
T: Eq + Hash,
B: Eq + Hash,
(): Vocabulary<Iri = T, BlankId = B>,
pub fn identify_all<G: Generator<(), M>>(&mut self, generator: &mut G)where M: Clone, 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.
sourcepub fn canonicalize_with(&mut self, buffer: &mut Buffer)
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.
sourcepub fn canonicalize(&mut self)
pub fn canonicalize(&mut self)
Puts this object literals into canonical form.
sourcepub fn as_iri(&self) -> Option<&T>
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.
sourcepub fn into_value(self) -> Option<Value<T, M>>
pub fn into_value(self) -> Option<Value<T, M>>
Converts this object as a value, if it is one.
sourcepub fn into_node(self) -> Option<Node<T, B, M>>
pub fn into_node(self) -> Option<Node<T, B, M>>
Converts this object into a node, if it is one.
sourcepub fn is_graph(&self) -> bool
pub fn is_graph(&self) -> bool
Tests if the object is a graph object (a node with a @graph
field).
sourcepub fn into_list(self) -> Option<List<T, B, M>>
pub fn into_list(self) -> Option<List<T, B, M>>
Converts this object into a list, if it is one.
sourcepub fn as_str(&self) -> Option<&str>where
T: AsRef<str>,
B: AsRef<str>,
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.
sourcepub fn language(&self) -> Option<LenientLanguageTag<'_>>
pub fn language(&self) -> Option<LenientLanguageTag<'_>>
If the object is a language-tagged value, Return its associated language.
sourcepub fn traverse(&self) -> Traverse<'_, T, B, M> ⓘ
pub fn traverse(&self) -> Traverse<'_, T, B, M> ⓘ
Returns an iterator over all fragments of this object, including the object itself.
Fragments include:
- objects
- key-value pairs,
- keys
- values
Trait Implementations§
source§impl<T, B, M> Any<T, B, M> for Object<T, B, M>
impl<T, B, M> Any<T, B, M> for Object<T, B, M>
fn as_ref(&self) -> Ref<'_, T, B, M>
fn id_entry<'a>(&'a self) -> Option<&'a Entry<Id<T, B>, M>>where M: 'a,
fn id<'a>(&'a self) -> Option<&'a Meta<Id<T, B>, M>>where M: 'a,
fn language<'a>(&'a self) -> Option<LenientLanguageTag<'_>>where T: 'a, B: 'a, M: 'a,
fn is_value(&self) -> bool
fn is_node(&self) -> bool
fn is_graph(&self) -> bool
fn is_list(&self) -> bool
source§impl<T, B, M: Clone, N: Vocabulary<Iri = T, BlankId = B>> IntoJsonWithContextMeta<M, N> for Object<T, B, M>
impl<T, B, M: Clone, N: Vocabulary<Iri = T, BlankId = B>> IntoJsonWithContextMeta<M, N> for Object<T, B, M>
source§impl<T, B, M> PartialEq<Object<T, B, M>> for Object<T, B, M>where
T: Eq + Hash,
B: Eq + Hash,
M: PartialEq,
impl<T, B, M> PartialEq<Object<T, B, M>> for Object<T, B, M>where T: Eq + Hash, B: Eq + Hash, M: PartialEq,
source§impl<T: Hash, B: Hash, M> StrippedHash for Object<T, B, M>
impl<T: Hash, B: Hash, M> StrippedHash for Object<T, B, M>
fn stripped_hash<H: Hasher>(&self, state: &mut H)
source§impl<T: Eq + Hash, B: Eq + Hash, M> StrippedPartialEq<Object<T, B, M>> for Object<T, B, M>
impl<T: Eq + Hash, B: Eq + Hash, M> StrippedPartialEq<Object<T, B, M>> for Object<T, B, M>
fn stripped_eq(&self, other: &Self) -> bool
source§impl<T: Eq + Hash, B: Eq + Hash, M> TryFromJson<T, B, M> for Object<T, B, M>
impl<T: Eq + Hash, B: Eq + Hash, M> TryFromJson<T, B, M> for Object<T, B, M>
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: Eq + Hash, B: Eq + Hash, M> TryFromJsonObject<T, B, M> for Object<T, B, M>
impl<T: Eq + Hash, B: Eq + Hash, M> TryFromJsonObject<T, B, M> for Object<T, B, M>
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>>
impl<T, B, M> Eq for Object<T, B, M>where T: Eq + Hash, B: Eq + Hash, M: Eq,
impl<T: Eq + Hash, B: Eq + Hash, M> StrippedEq for Object<T, B, M>
Auto Trait Implementations§
impl<T, B, M> RefUnwindSafe for Object<T, B, M>where B: RefUnwindSafe, M: RefUnwindSafe, T: RefUnwindSafe,
impl<T, B, M> Send for Object<T, B, M>where B: Send, M: Send, T: Send,
impl<T, B, M> Sync for Object<T, B, M>where B: Sync, M: Sync, T: Sync,
impl<T, B, M> Unpin for Object<T, B, M>where M: Unpin, T: Unpin,
impl<T, B, M> UnwindSafe for Object<T, B, M>where B: UnwindSafe, M: UnwindSafe, T: UnwindSafe,
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
fn equivalent(&self, key: &K) -> bool
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.