pub struct Document<I = IriBuf, B = BlankIdBuf> { /* private fields */ }Expand description
JSON-LD document in both compact and expanded form.
Implementations§
Source§impl<I, B> Document<I, B>
impl<I, B> Document<I, B>
Sourcepub fn new(remote: RemoteDocument<I>, expanded: ExpandedDocument<I, B>) -> Self
pub fn new(remote: RemoteDocument<I>, expanded: ExpandedDocument<I, B>) -> Self
Creates a new Document.
Sourcepub fn into_remote(self) -> RemoteDocument<I>
pub fn into_remote(self) -> RemoteDocument<I>
Consumes the document, returning its remote (compact) form.
Sourcepub fn into_compact(self) -> Value
pub fn into_compact(self) -> Value
Consumes the document, returning its compact form as a JSON value.
Sourcepub fn into_expanded(self) -> ExpandedDocument<I, B>
pub fn into_expanded(self) -> ExpandedDocument<I, B>
Consumes the document, returning its expanded form.
Sourcepub fn into_parts(self) -> DocumentParts<I, B>
pub fn into_parts(self) -> DocumentParts<I, B>
Consumes the document, returning its remote and expanded forms.
Sourcepub fn as_remote(&self) -> &RemoteDocument<I>
pub fn as_remote(&self) -> &RemoteDocument<I>
Returns the remote (compact) form of the document.
Sourcepub fn as_compact(&self) -> &Value
pub fn as_compact(&self) -> &Value
Returns the compact form of the document as a JSON value.
Sourcepub fn as_expanded(&self) -> &ExpandedDocument<I, B>
pub fn as_expanded(&self) -> &ExpandedDocument<I, B>
Returns the expanded form of the document.
Methods from Deref<Target = ExpandedDocument<I, B>>§
Sourcepub fn objects(&self) -> &[IndexedObject<T, B>] ⓘ
pub fn objects(&self) -> &[IndexedObject<T, B>] ⓘ
Returns the top-level objects of the document, in insertion order.
Sourcepub fn iter(&self) -> Iter<'_, IndexedObject<T, B>> ⓘ
pub fn iter(&self) -> Iter<'_, IndexedObject<T, B>> ⓘ
Returns an iterator over the top-level objects of the document, in insertion order.
Sourcepub fn traverse(&self) -> Traverse<'_, T, B> ⓘ
pub fn traverse(&self) -> Traverse<'_, T, B> ⓘ
Returns an iterator that visits every fragment of the document: each top-level object and, recursively, everything it contains.
Sourcepub fn count(&self, f: impl FnMut(&FragmentRef<'_, T, B>) -> bool) -> usize
pub fn count(&self, f: impl FnMut(&FragmentRef<'_, T, B>) -> bool) -> usize
Counts the fragments of the document matching the given predicate.
Sourcepub fn blank_ids(&self) -> HashSet<&B>
pub fn blank_ids(&self) -> HashSet<&B>
Returns the set of all blank identifiers in the given document.
Sourcepub fn main_node(&self) -> Option<&Node<T, B>>
pub fn main_node(&self) -> Option<&Node<T, B>>
Returns the main node object of the document, if any.
The main node is the unique top level (root) node object. If multiple
node objects are on the root, None is returned.
Sourcepub fn contains(&self, object: &IndexedObject<T, B>) -> bool
pub fn contains(&self, object: &IndexedObject<T, B>) -> bool
Checks whether an equal object is present.
Sourcepub fn generate_node_map_with<V: VocabularyMut<Iri = T, BlankId = B>, G: LocalGenerator>(
&self,
vocabulary: &mut V,
generator: G,
) -> Result<NodeMap<T, B>, NodeMapError<T, B>>
pub fn generate_node_map_with<V: VocabularyMut<Iri = T, BlankId = B>, G: LocalGenerator>( &self, vocabulary: &mut V, generator: G, ) -> Result<NodeMap<T, B>, NodeMapError<T, B>>
Builds the node map of this document using the given vocabulary and blank node generator.
§Errors
Returns an error when the generator runs out of identifiers, or when two nodes disagree on an @index.
Trait Implementations§
Source§impl<I, B> Borrow<ExpandedDocument<I, B>> for Document<I, B>
impl<I, B> Borrow<ExpandedDocument<I, B>> for Document<I, B>
Source§fn borrow(&self) -> &ExpandedDocument<I, B>
fn borrow(&self) -> &ExpandedDocument<I, B>
Source§impl<I, B> Borrow<RemoteDocument<I>> for Document<I, B>
impl<I, B> Borrow<RemoteDocument<I>> for Document<I, B>
Source§fn borrow(&self) -> &RemoteDocument<I>
fn borrow(&self) -> &RemoteDocument<I>
impl<I: Eq + Hash, B: Eq + Hash> Eq for Document<I, B>
Auto Trait Implementations§
impl<I, B> Freeze for Document<I, B>
impl<I, B> RefUnwindSafe for Document<I, B>
impl<I, B> Send for Document<I, B>
impl<I, B> Sync for Document<I, B>
impl<I, B> Unpin for Document<I, B>
impl<I, B> UnsafeUnpin for Document<I, B>
impl<I, B> UnwindSafe for Document<I, B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
Source§fn as_unordered(&self) -> &Unordered<T>
fn as_unordered(&self) -> &Unordered<T>
Unordered reference.impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
self is equivalent to key.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.