pub trait JsonLdProcessor<I, M> {
Show 25 methods fn compare_full<'a, B, C, N, L>(
        &'a self,
        other: &'a Self,
        vocabulary: &'a mut N,
        loader: &'a mut L,
        options: Options<I, M, C>,
        warnings: impl 'a + Send + WarningHandler<N, M> + WarningHandler<B, N, M>
    ) -> BoxFuture<'_, CompareResult<I, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
; fn expand_full<'a, B, C, N, L>(
        &'a self,
        vocabulary: &'a mut N,
        loader: &'a mut L,
        options: Options<I, M, C>,
        warnings: impl 'a + Send + WarningHandler<N, M> + WarningHandler<B, N, M>
    ) -> BoxFuture<'_, ExpandResult<I, B, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
; fn compact_full<'a, B, C, N, L>(
        &'a self,
        vocabulary: &'a mut N,
        context: RemoteDocumentReference<I, M, C>,
        loader: &'a mut L,
        options: Options<I, M, C>,
        warnings: impl 'a + Send + WarningHandler<N, M> + WarningHandler<B, N, M>
    ) -> BoxFuture<'a, CompactResult<I, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
; fn flatten_full<'a, B, C, N, L>(
        &'a self,
        vocabulary: &'a mut N,
        generator: &'a mut impl Send + Generator<N, M>,
        context: Option<RemoteDocumentReference<I, M, C>>,
        loader: &'a mut L,
        options: Options<I, M, C>,
        warnings: impl 'a + Send + WarningHandler<N, M> + WarningHandler<B, N, M>
    ) -> BoxFuture<'a, Result<MetaValue<M>, FlattenError<I, B, M, <L as Loader<I, M>>::Error, <L as ContextLoader<I, M>>::ContextError>>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
; fn compare_with_using<'a, B, C, N, L>(
        &'a self,
        other: &'a Self,
        vocabulary: &'a mut N,
        loader: &'a mut L,
        options: Options<I, M, C>
    ) -> BoxFuture<'_, CompareResult<I, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
, { ... } fn compare_with<'a, B, N, L>(
        &'a self,
        other: &'a Self,
        vocabulary: &'a mut N,
        loader: &'a mut L
    ) -> BoxFuture<'_, CompareResult<I, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: 'a + Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<Value<M>>,
        L::ContextError: Send
, { ... } fn compare_using<'a, B, C, L>(
        &'a self,
        other: &'a Self,
        loader: &'a mut L,
        options: Options<I, M, C>
    ) -> BoxFuture<'_, CompareResult<I, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        (): Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
, { ... } fn compare<'a, B, L>(
        &'a self,
        other: &'a Self,
        loader: &'a mut L
    ) -> BoxFuture<'_, CompareResult<I, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        (): Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: 'a + Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<Value<M>>,
        L::ContextError: Send
, { ... } fn expand_with_using<'a, B, C, N, L>(
        &'a self,
        vocabulary: &'a mut N,
        loader: &'a mut L,
        options: Options<I, M, C>
    ) -> BoxFuture<'_, ExpandResult<I, B, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
, { ... } fn expand_with<'a, B, N, L>(
        &'a self,
        vocabulary: &'a mut N,
        loader: &'a mut L
    ) -> BoxFuture<'_, ExpandResult<I, B, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: 'a + Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<Value<M>>,
        L::ContextError: Send
, { ... } fn expand_using<'a, B, C, L>(
        &'a self,
        loader: &'a mut L,
        options: Options<I, M, C>
    ) -> BoxFuture<'_, ExpandResult<I, B, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        (): Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
, { ... } fn expand<'a, B, L>(
        &'a self,
        loader: &'a mut L
    ) -> BoxFuture<'_, ExpandResult<I, B, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        (): Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: 'a + Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<Value<M>>,
        L::ContextError: Send
, { ... } fn compact_with_using<'a, B, C, N, L>(
        &'a self,
        vocabulary: &'a mut N,
        context: RemoteDocumentReference<I, M, C>,
        loader: &'a mut L,
        options: Options<I, M, C>
    ) -> BoxFuture<'a, CompactResult<I, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
, { ... } fn compact_with<'a, B, C, N, L>(
        &'a self,
        vocabulary: &'a mut N,
        context: RemoteDocumentReference<I, M, C>,
        loader: &'a mut L
    ) -> BoxFuture<'a, CompactResult<I, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
, { ... } fn compact_using<'a, B, C, L>(
        &'a self,
        context: RemoteDocumentReference<I, M, C>,
        loader: &'a mut L,
        options: Options<I, M, C>
    ) -> BoxFuture<'a, CompactResult<I, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        (): Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
, { ... } fn compact<'a, B, C, L>(
        &'a self,
        context: RemoteDocumentReference<I, M, C>,
        loader: &'a mut L
    ) -> BoxFuture<'a, CompactResult<I, M, L>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        (): Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
, { ... } fn flatten_with_using<'a, B, C, N, L>(
        &'a self,
        vocabulary: &'a mut N,
        generator: &'a mut impl Send + Generator<N, M>,
        loader: &'a mut L,
        options: Options<I, M, C>
    ) -> BoxFuture<'a, Result<MetaValue<M>, FlattenError<I, B, M, <L as Loader<I, M>>::Error, <L as ContextLoader<I, M>>::ContextError>>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
, { ... } fn flatten_with<'a, B, N, L>(
        &'a self,
        vocabulary: &'a mut N,
        generator: &'a mut impl Send + Generator<N, M>,
        loader: &'a mut L
    ) -> BoxFuture<'a, Result<MetaValue<M>, FlattenError<I, B, M, <L as Loader<I, M>>::Error, <L as ContextLoader<I, M>>::ContextError>>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: 'a + Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<Value<M>>,
        L::ContextError: Send
, { ... } fn flatten_using<'a, B, C, L>(
        &'a self,
        generator: &'a mut impl Send + Generator<(), M>,
        loader: &'a mut L,
        options: Options<I, M, C>
    ) -> BoxFuture<'a, Result<MetaValue<M>, FlattenError<I, B, M, <L as Loader<I, M>>::Error, <L as ContextLoader<I, M>>::ContextError>>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        (): Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send
, { ... } fn flatten<'a, B, L>(
        &'a self,
        generator: &'a mut impl Send + Generator<(), M>,
        loader: &'a mut L
    ) -> BoxFuture<'a, Result<MetaValue<M>, FlattenError<I, B, M, <L as Loader<I, M>>::Error, <L as ContextLoader<I, M>>::ContextError>>>
    where
        I: Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        (): Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: 'a + Clone + Send + Sync,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<Value<M>>,
        L::ContextError: Send
, { ... } fn to_rdf_full<'a, B, C, N, G, L>(
        &'a self,
        vocabulary: &'a mut N,
        generator: &'a mut G,
        loader: &'a mut L,
        options: Options<I, M, C>,
        warnings: impl 'a + Send + WarningHandler<N, M> + WarningHandler<B, N, M>
    ) -> BoxFuture<'_, ToRdfResult<'a, N, M, G, L>>
    where
        I: 'a + Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: 'a + Clone + Send + Sync,
        G: Send + Generator<N, M>,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send,
        Self: Sync
, { ... } fn to_rdf_with_using<'a, B, C, N, G, L>(
        &'a self,
        vocabulary: &'a mut N,
        generator: &'a mut G,
        loader: &'a mut L,
        options: Options<I, M, C>
    ) -> BoxFuture<'_, ToRdfResult<'a, N, M, G, L>>
    where
        I: 'a + Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: 'a + Clone + Send + Sync,
        G: Send + Generator<N, M>,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send,
        Self: Sync
, { ... } fn to_rdf_with<'a, B, N, G, L>(
        &'a self,
        vocabulary: &'a mut N,
        generator: &'a mut G,
        loader: &'a mut L
    ) -> BoxFuture<'_, ToRdfResult<'a, N, M, G, L>>
    where
        I: 'a + Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        N: Send + Sync + VocabularyMut<Iri = I, BlankId = B>,
        M: 'a + Clone + Send + Sync,
        G: Send + Generator<N, M>,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<Value<M>>,
        L::ContextError: Send,
        Self: Sync
, { ... } fn to_rdf_using<'a, B, C, G, L>(
        &'a self,
        generator: &'a mut G,
        loader: &'a mut L,
        options: Options<I, M, C>
    ) -> BoxFuture<'_, ToRdfResult<'a, (), M, G, L>>
    where
        I: 'a + Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        C: 'a + ProcessMeta<I, B, M> + From<Value<M>>,
        (): VocabularyMut<Iri = I, BlankId = B>,
        M: 'a + Clone + Send + Sync,
        G: Send + Generator<(), M>,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<C>,
        L::ContextError: Send,
        Self: Sync
, { ... } fn to_rdf<'a, B, G, L>(
        &'a self,
        generator: &'a mut G,
        loader: &'a mut L
    ) -> BoxFuture<'_, ToRdfResult<'a, (), M, G, L>>
    where
        I: 'a + Clone + Eq + Hash + Send + Sync,
        B: 'a + Clone + Eq + Hash + Send + Sync,
        (): VocabularyMut<Iri = I, BlankId = B>,
        M: 'a + Clone + Send + Sync,
        G: Send + Generator<(), M>,
        L: Loader<I, M> + ContextLoader<I, M> + Send + Sync,
        L::Output: Into<Value<M>>,
        L::Error: Send,
        L::Context: Into<Value<M>>,
        L::ContextError: Send,
        Self: Sync
, { ... }
}
Expand description

Application Programming Interface.

The JsonLdProcessor interface is the high-level programming structure that developers use to access the JSON-LD transformation methods.

It is notably implemented for the RemoteDocument<I, M, json_syntax::Value<M>> and RemoteDocumentReference<I, M, json_syntax::Value<M>> types.

Methods naming

Each processing function is declined in four variants depending on your needs, with the following suffix convention:

  • _full: function with all the possible options. This is the only way to specify a custom warning handler.
  • _with: allows passing a custom Vocabulary.
  • _using: allows passing custom Options.
  • _with_using: allows passing both a custom Vocabulary and custom Options.
  • no suffix: minimum parameters. No custom vocabulary: IriBuf and BlankIdBuf must be used as IRI and blank node id respectively.

Example

use static_iref::iri;
use json_ld::{JsonLdProcessor, RemoteDocumentReference};

let input = RemoteDocumentReference::iri(iri!("https://example.com/sample.jsonld").to_owned());

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(iri!("https://example.com/").to_owned(), "examples");

let expanded = input.expand(&mut loader)
  .await
  .expect("expansion failed");

Required Methods§

Compare this document against other with a custom vocabulary using the given options and warnings handler.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::IriVocabularyMut;
use locspan::Meta;

let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input1 = RemoteDocumentReference::iri(iri);
let input2 = RemoteDocumentReference::iri(iri);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");
  
assert!(input1.compare_full(
  &input2,
  &mut vocabulary,
  &mut loader,
  Options::<_, _>::default(),
  warning::PrintWith
).await.expect("comparison failed"));

Expand the document with the given vocabulary and loader, using the given options and warning handler.

On success, the result is an ExpandedDocument.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::IriVocabularyMut;
// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri_index = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input = RemoteDocumentReference::iri(iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");

let expanded = input
  .expand_full(
    &mut vocabulary,
    &mut loader,
    Options::<_, _>::default(),
    warning::PrintWith
  )
  .await
  .expect("expansion failed");

Compact the document relative to context with the given vocabulary and loader, using the given options and warning handler.

On success, the result is an syntax::Value wrapped inside a Meta.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::IriVocabularyMut;
// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri_index = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input = RemoteDocumentReference::iri(iri_index);

let context_iri_index = vocabulary.insert(iri!("https://example.com/context.jsonld"));
let context = RemoteDocumentReference::context_iri(context_iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");

let compact = input
  .compact_full(
    &mut vocabulary,
    context,
    &mut loader,
    Options::<_, _>::default(),
    warning::PrintWith
  )
  .await
  .expect("compaction failed");

Flatten the document with the given vocabulary, generator and loader, using the given options and warning handler.

An optional context can be given to compact the document.

Flattening requires assigning an identifier to nested anonymous nodes, which is why the flattening functions take an rdf_types::MetaGenerator as parameter. This generator is in charge of creating new fresh identifiers (with their metadata). The most common generator is rdf_types::generator::Blank that creates blank node identifiers.

On success, the result is a FlattenedDocument, which is a list of indexed nodes.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::IriVocabularyMut;
use locspan::{Location, Span};

// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri_index = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input = RemoteDocumentReference::iri(iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");

let mut generator = rdf_types::generator::Blank::new().with_metadata(
  // Each blank id will be associated to the document URL with a dummy span.
  Location::new(vocabulary.insert(iri!("https://example.com/")), Span::default())
);

let nodes = input
  .flatten_full(
    &mut vocabulary,
    &mut generator,
    None,
    &mut loader,
    Options::<_, _>::default(),
    warning::PrintWith
  )
  .await
  .expect("flattening failed");

Provided Methods§

Compare this document against other with a custom vocabulary using the given options.

Warnings are ignored.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference};
use rdf_types::IriVocabularyMut;
use locspan::Meta;

let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input1 = RemoteDocumentReference::iri(iri);
let input2 = RemoteDocumentReference::iri(iri);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");
  
assert!(input1.compare_with_using(
  &input2,
  &mut vocabulary,
  &mut loader,
  Options::<_, _>::default()
).await.expect("comparison failed"));

Compare this document against other with a custom vocabulary.

Default options are used. Warnings are ignored.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference};
use rdf_types::IriVocabularyMut;
use locspan::Meta;

let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input1 = RemoteDocumentReference::iri(iri);
let input2 = RemoteDocumentReference::iri(iri);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");
  
assert!(input1.compare_with(
  &input2,
  &mut vocabulary,
  &mut loader
).await.expect("comparison failed"));

Compare this document against other using the given options.

Warnings are ignored.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference};
use locspan::Meta;

let iri = iri!("https://example.com/sample.jsonld").to_owned();
let input1 = RemoteDocumentReference::iri(iri.clone());
let input2 = RemoteDocumentReference::iri(iri);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(iri!("https://example.com/").to_owned(), "examples");
  
assert!(input1.compare_using(
  &input2,
  &mut loader,
  Options::<_, _>::default()
).await.expect("comparison failed"));

Compare this document against other with a custom vocabulary.

Default options are used. Warnings are ignored.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference};
use locspan::Meta;

let iri = iri!("https://example.com/sample.jsonld").to_owned();
let input1 = RemoteDocumentReference::iri(iri.clone());
let input2 = RemoteDocumentReference::iri(iri);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(iri!("https://example.com/").to_owned(), "examples");
  
assert!(input1.compare(
  &input2,
  &mut loader
).await.expect("comparison failed"));

Expand the document with the given vocabulary and loader, using the given options.

Warnings are ignored. On success, the result is an ExpandedDocument.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::IriVocabularyMut;
// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri_index = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input = RemoteDocumentReference::iri(iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");

let expanded = input
  .expand_with_using(
    &mut vocabulary,
    &mut loader,
    Options::<_, _>::default()
  )
  .await
  .expect("expansion failed");

Expand the document with the given vocabulary and loader.

Default options are used. Warnings are ignored. On success, the result is an ExpandedDocument.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::IriVocabularyMut;
// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri_index = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input = RemoteDocumentReference::iri(iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");

let expanded = input
  .expand_with(
    &mut vocabulary,
    &mut loader
  )
  .await
  .expect("expansion failed");

Expand the document with the given loader using the given options.

Warnings are ignored. On success, the result is an ExpandedDocument.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};

let iri = iri!("https://example.com/sample.jsonld").to_owned();
let input = RemoteDocumentReference::iri(iri);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(iri!("https://example.com/").to_owned(), "examples");

let expanded = input
  .expand_using(
    &mut loader,
    Options::<_, _>::default()
  )
  .await
  .expect("expansion failed");

Expand the document with the given loader.

Default options are used. Warnings are ignored. On success, the result is an ExpandedDocument.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};

let iri = iri!("https://example.com/sample.jsonld").to_owned();
let input = RemoteDocumentReference::iri(iri);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(iri!("https://example.com/").to_owned(), "examples");

let expanded = input
  .expand(&mut loader)
  .await
  .expect("expansion failed");

Compact the document relative to context with the given vocabulary and loader, using the given options.

Warnings are ignored. On success, the result is an syntax::Value wrapped inside a Meta.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::IriVocabularyMut;
// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri_index = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input = RemoteDocumentReference::iri(iri_index);

let context_iri_index = vocabulary.insert(iri!("https://example.com/context.jsonld"));
let context = RemoteDocumentReference::context_iri(context_iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");

let compact = input
  .compact_with_using(
    &mut vocabulary,
    context,
    &mut loader,
    Options::<_, _>::default()
  )
  .await
  .expect("compaction failed");

Compact the document relative to context with the given vocabulary and loader.

Default options are used. Warnings are ignored. On success, the result is an syntax::Value wrapped inside a Meta.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::IriVocabularyMut;
// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri_index = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input = RemoteDocumentReference::iri(iri_index);

let context_iri_index = vocabulary.insert(iri!("https://example.com/context.jsonld"));
let context = RemoteDocumentReference::context_iri(context_iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");

let compact = input
  .compact_with(
    &mut vocabulary,
    context,
    &mut loader
  )
  .await
  .expect("compaction failed");

Compact the document relative to context with the given loader, using the given options.

Warnings are ignored. On success, the result is an syntax::Value wrapped inside a Meta.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};

let iri = iri!("https://example.com/sample.jsonld").to_owned();
let input = RemoteDocumentReference::iri(iri);

let context_iri = iri!("https://example.com/context.jsonld").to_owned();
let context = RemoteDocumentReference::context_iri(context_iri);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(iri!("https://example.com/").to_owned(), "examples");

let compact = input
  .compact_using(
    context,
    &mut loader,
    Options::<_, _>::default()
  )
  .await
  .expect("compaction failed");

Compact the document relative to context with the given loader.

Default options are used. Warnings are ignored. On success, the result is an syntax::Value wrapped inside a Meta.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};

let iri = iri!("https://example.com/sample.jsonld").to_owned();
let input = RemoteDocumentReference::iri(iri);

let context_iri = iri!("https://example.com/context.jsonld").to_owned();
let context = RemoteDocumentReference::context_iri(context_iri);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(iri!("https://example.com/").to_owned(), "examples");

let compact = input
  .compact(
    context,
    &mut loader
  )
  .await
  .expect("compaction failed");

Flatten the document with the given vocabulary, generator and loader, using the given options.

Flattening requires assigning an identifier to nested anonymous nodes, which is why the flattening functions take an rdf_types::MetaGenerator as parameter. This generator is in charge of creating new fresh identifiers (with their metadata). The most common generator is rdf_types::generator::Blank that creates blank node identifiers.

Warnings are ignored. On success, the result is a FlattenedDocument, which is a list of indexed nodes.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::IriVocabularyMut;
use locspan::{Location, Span};

// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri_index = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input = RemoteDocumentReference::iri(iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");

let mut generator = rdf_types::generator::Blank::new().with_metadata(
  // Each blank id will be associated to the document URL with a dummy span.
  Location::new(vocabulary.insert(iri!("https://example.com/")), Span::default())
);

let nodes = input
  .flatten_with_using(
    &mut vocabulary,
    &mut generator,
    &mut loader,
    Options::<_, _>::default()
  )
  .await
  .expect("flattening failed");

Flatten the document with the given vocabulary, generator and loader.

Flattening requires assigning an identifier to nested anonymous nodes, which is why the flattening functions take an rdf_types::MetaGenerator as parameter. This generator is in charge of creating new fresh identifiers (with their metadata). The most common generator is rdf_types::generator::Blank that creates blank node identifiers.

Default options are used. Warnings are ignored. On success, the result is a FlattenedDocument, which is a list of indexed nodes.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::IriVocabularyMut;
use locspan::{Location, Span};

// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri_index = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input = RemoteDocumentReference::iri(iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");

let mut generator = rdf_types::generator::Blank::new().with_metadata(
  // Each blank id will be associated to the document URL with a dummy span.
  Location::new(vocabulary.insert(iri!("https://example.com/")), Span::default())
);

let nodes = input
  .flatten_with(
    &mut vocabulary,
    &mut generator,
    &mut loader
  )
  .await
  .expect("flattening failed");

Flatten the document with the given generator, loader and using the given options.

Flattening requires assigning an identifier to nested anonymous nodes, which is why the flattening functions take an rdf_types::MetaGenerator as parameter. This generator is in charge of creating new fresh identifiers (with their metadata). The most common generator is rdf_types::generator::Blank that creates blank node identifiers.

Warnings are ignored. On success, the result is a FlattenedDocument, which is a list of indexed nodes.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use locspan::{Location, Span};

let iri = iri!("https://example.com/sample.jsonld").to_owned();
let input = RemoteDocumentReference::iri(iri);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(iri!("https://example.com/").to_owned(), "examples");

let mut generator = rdf_types::generator::Blank::new().with_metadata(
  // Each blank id will be associated to the document URL with a dummy span.
  Location::new(iri!("https://example.com/").to_owned(), Span::default())
);

let nodes = input
  .flatten_using(
    &mut generator,
    &mut loader,
    Options::<_, _>::default()
  )
  .await
  .expect("flattening failed");

Flatten the document with the given generator and loader.

Flattening requires assigning an identifier to nested anonymous nodes, which is why the flattening functions take an rdf_types::MetaGenerator as parameter. This generator is in charge of creating new fresh identifiers (with their metadata). The most common generator is rdf_types::generator::Blank that creates blank node identifiers.

Default options are used. Warnings are ignored. On success, the result is a FlattenedDocument, which is a list of indexed nodes.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use locspan::{Location, Span};

let iri = iri!("https://example.com/sample.jsonld").to_owned();
let input = RemoteDocumentReference::iri(iri);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(iri!("https://example.com/").to_owned(), "examples");

let mut generator = rdf_types::generator::Blank::new().with_metadata(
  // Each blank id will be associated to the document URL with a dummy span.
  Location::new(iri!("https://example.com/").to_owned(), Span::default())
);

let nodes = input
  .flatten(
    &mut generator,
    &mut loader
  )
  .await
  .expect("flattening failed");

Serializes the document into an RDF dataset with a custom vocabulary using the given options and warnings handler.

Expands the document and returns a ToRdf instance from which an iterator over the RDF quads defined by the document can be accessed using the ToRdf::quads method.

The quads will have type rdf::Quads which borrows the subject, predicate and graph values from the documents if possible using Cow. If you prefer to have quads owning the values directly you can use the ToRdf::cloned_quads method or call the rdf::Quads::cloned method method form the value returned by ToRdf::quads.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::{IriVocabularyMut, Quad};
use locspan::{Location, Span};

// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri_index = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input = RemoteDocumentReference::iri(iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");

let mut generator = rdf_types::generator::Blank::new().with_metadata(
  // Each blank id will be associated to the document URL with a dummy span.
  Location::new(vocabulary.insert(iri!("https://example.com/")), Span::default())
);

let mut rdf = input
  .to_rdf_full(
    &mut vocabulary,
    &mut generator,
    &mut loader,
    Options::<_, _>::default(),
    warning::PrintWith
  )
  .await
  .expect("flattening failed");

for Quad(_s, _p, _o, _g) in rdf.quads() {
  // ...
}

Serializes the document into an RDF dataset with a custom vocabulary using the given options.

Expands the document and returns a ToRdf instance from which an iterator over the RDF quads defined by the document can be accessed using the ToRdf::quads method.

The quads will have type rdf::Quads which borrows the subject, predicate and graph values from the documents if possible using Cow. If you prefer to have quads owning the values directly you can use the ToRdf::cloned_quads method or call the rdf::Quads::cloned method method form the value returned by ToRdf::quads.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::{IriVocabularyMut, Quad};
use locspan::{Location, Span};

// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri_index = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input = RemoteDocumentReference::iri(iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");

let mut generator = rdf_types::generator::Blank::new().with_metadata(
  // Each blank id will be associated to the document URL with a dummy span.
  Location::new(vocabulary.insert(iri!("https://example.com/")), Span::default())
);

let mut rdf = input
  .to_rdf_with_using(
    &mut vocabulary,
    &mut generator,
    &mut loader,
    Options::<_, _>::default()
  )
  .await
  .expect("flattening failed");

for Quad(_s, _p, _o, _g) in rdf.quads() {
  // ...
}

Serializes the document into an RDF dataset with a custom vocabulary.

Default options are used.

Expands the document and returns a ToRdf instance from which an iterator over the RDF quads defined by the document can be accessed using the ToRdf::quads method.

The quads will have type rdf::Quads which borrows the subject, predicate and graph values from the documents if possible using Cow. If you prefer to have quads owning the values directly you can use the ToRdf::cloned_quads method or call the rdf::Quads::cloned method method form the value returned by ToRdf::quads.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::{IriVocabularyMut, Quad};
use locspan::{Location, Span};

// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: rdf_types::IndexVocabulary = rdf_types::IndexVocabulary::new();

let iri_index = vocabulary.insert(iri!("https://example.com/sample.jsonld"));
let input = RemoteDocumentReference::iri(iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(vocabulary.insert(iri!("https://example.com/")), "examples");

let mut generator = rdf_types::generator::Blank::new().with_metadata(
  // Each blank id will be associated to the document URL with a dummy span.
  Location::new(vocabulary.insert(iri!("https://example.com/")), Span::default())
);

let mut rdf = input
  .to_rdf_with(
    &mut vocabulary,
    &mut generator,
    &mut loader
  )
  .await
  .expect("flattening failed");

for Quad(_s, _p, _o, _g) in rdf.quads() {
  // ...
}

Serializes the document into an RDF dataset using the given options.

Expands the document and returns a ToRdf instance from which an iterator over the RDF quads defined by the document can be accessed using the ToRdf::quads method.

The quads will have type rdf::Quads which borrows the subject, predicate and graph values from the documents if possible using Cow. If you prefer to have quads owning the values directly you can use the ToRdf::cloned_quads method or call the rdf::Quads::cloned method method form the value returned by ToRdf::quads.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::Quad;
use locspan::{Location, Span};

let iri_index = iri!("https://example.com/sample.jsonld").to_owned();
let input = RemoteDocumentReference::iri(iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(iri!("https://example.com/").to_owned(), "examples");

let mut generator = rdf_types::generator::Blank::new().with_metadata(
  // Each blank id will be associated to the document URL with a dummy span.
  Location::new(iri!("https://example.com/").to_owned(), Span::default())
);

let mut rdf = input
  .to_rdf_using(
    &mut generator,
    &mut loader,
    Options::<_, _>::default()
  )
  .await
  .expect("flattening failed");

for Quad(s, p, o, g) in rdf.quads() {
  println!("subject: {}", s);
  println!("predicate: {}", p);
  println!("object: {}", o);

  if let Some(g) = g {
    println!("graph: {}", g);
  }
}

Serializes the document into an RDF dataset.

Default options are used.

Expands the document and returns a ToRdf instance from which an iterator over the RDF quads defined by the document can be accessed using the ToRdf::quads method.

The quads will have type rdf::Quads which borrows the subject, predicate and graph values from the documents if possible using Cow. If you prefer to have quads owning the values directly you can use the ToRdf::cloned_quads method or call the rdf::Quads::cloned method method form the value returned by ToRdf::quads.

Example
use static_iref::iri;
use json_ld::{JsonLdProcessor, Options, RemoteDocumentReference, warning};
use rdf_types::Quad;
use locspan::{Location, Span};

let iri_index = iri!("https://example.com/sample.jsonld").to_owned();
let input = RemoteDocumentReference::iri(iri_index);

// Use `FsLoader` to redirect any URL starting with `https://example.com/` to
// the local `example` directory. No HTTP query.
let mut loader = json_ld::FsLoader::default();
loader.mount(iri!("https://example.com/").to_owned(), "examples");

let mut generator = rdf_types::generator::Blank::new().with_metadata(
  // Each blank id will be associated to the document URL with a dummy span.
  Location::new(iri!("https://example.com/").to_owned(), Span::default())
);

let mut rdf = input
  .to_rdf(
    &mut generator,
    &mut loader
  )
  .await
  .expect("flattening failed");

for Quad(s, p, o, g) in rdf.quads() {
  println!("subject: {}", s);
  println!("predicate: {}", p);
  println!("object: {}", o);

  if let Some(g) = g {
    println!("graph: {}", g);
  }
}

Implementors§