Trait JsonLdProcessor

Source
pub trait JsonLdProcessor<Iri>: Sized {
Show 29 methods // Required methods async fn compare_full<N>( &self, other: &Self, vocabulary: &mut N, loader: &impl Loader, options: Options<Iri>, warnings: impl WarningHandler<N> + WarningHandler<N>, ) -> CompareResult where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: Clone + Eq + Hash; async fn expand_full<N>( &self, vocabulary: &mut N, loader: &impl Loader, options: Options<Iri>, warnings: impl WarningHandler<N> + WarningHandler<N>, ) -> ExpandResult<Iri, N::BlankId> where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: Clone + Eq + Hash; async fn into_document_full<'a, N>( self, vocabulary: &'a mut N, loader: &'a impl Loader, options: Options<Iri>, warnings: impl 'a + WarningHandler<N> + WarningHandler<N>, ) -> IntoDocumentResult<Iri, N::BlankId> where N: VocabularyMut<Iri = Iri>, Iri: 'a + Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash; async fn compact_full<'a, N>( &'a self, vocabulary: &'a mut N, context: RemoteContextReference<Iri>, loader: &'a impl Loader, options: Options<Iri>, warnings: impl 'a + WarningHandler<N> + WarningHandler<N>, ) -> CompactResult where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash; async fn flatten_full<'a, N>( &'a self, vocabulary: &'a mut N, generator: &'a mut impl Generator<N>, context: Option<RemoteContextReference<Iri>>, loader: &'a impl Loader, options: Options<Iri>, warnings: impl 'a + WarningHandler<N> + WarningHandler<N>, ) -> FlattenResult<Iri, N::BlankId> where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash; // Provided methods async fn compare_with_using<'a, N>( &'a self, other: &'a Self, vocabulary: &'a mut N, loader: &'a impl Loader, options: Options<Iri>, ) -> CompareResult where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash { ... } async fn compare_with<'a, N>( &'a self, other: &'a Self, vocabulary: &'a mut N, loader: &'a impl Loader, ) -> CompareResult where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash { ... } async fn compare_using<'a>( &'a self, other: &'a Self, loader: &'a impl Loader, options: Options<Iri>, ) -> CompareResult where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash { ... } async fn compare<'a>( &'a self, other: &'a Self, loader: &'a impl Loader, ) -> CompareResult where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash { ... } async fn expand_with_using<'a, N>( &'a self, vocabulary: &'a mut N, loader: &'a impl Loader, options: Options<Iri>, ) -> ExpandResult<Iri, N::BlankId> where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash { ... } async fn expand_with<'a, N>( &'a self, vocabulary: &'a mut N, loader: &'a impl Loader, ) -> ExpandResult<Iri, N::BlankId> where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash { ... } async fn expand_using<'a>( &'a self, loader: &'a impl Loader, options: Options<Iri>, ) -> ExpandResult<Iri, BlankIdBuf> where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash { ... } async fn expand<'a>( &'a self, loader: &'a impl Loader, ) -> ExpandResult<Iri, BlankIdBuf> where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash { ... } async fn into_document_with_using<'a, N>( self, vocabulary: &'a mut N, loader: &'a impl Loader, options: Options<Iri>, ) -> IntoDocumentResult<Iri, N::BlankId> where N: VocabularyMut<Iri = Iri>, Iri: 'a + Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash { ... } async fn into_document_with<'a, N>( self, vocabulary: &'a mut N, loader: &'a impl Loader, ) -> IntoDocumentResult<Iri, N::BlankId> where N: VocabularyMut<Iri = Iri>, Iri: 'a + Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash { ... } async fn into_document<'a>( self, loader: &'a impl Loader, ) -> IntoDocumentResult<Iri, BlankIdBuf> where (): VocabularyMut<Iri = Iri>, Iri: 'a + Clone + Eq + Hash { ... } async fn compact_with_using<'a, N>( &'a self, vocabulary: &'a mut N, context: RemoteContextReference<Iri>, loader: &'a impl Loader, options: Options<Iri>, ) -> CompactResult where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash { ... } async fn compact_with<'a, N>( &'a self, vocabulary: &'a mut N, context: RemoteContextReference<Iri>, loader: &'a impl Loader, ) -> CompactResult where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash { ... } async fn compact_using<'a>( &'a self, context: RemoteContextReference<Iri>, loader: &'a impl Loader, options: Options<Iri>, ) -> CompactResult where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash { ... } async fn compact<'a>( &'a self, context: RemoteContextReference<Iri>, loader: &'a impl Loader, ) -> CompactResult where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash { ... } async fn flatten_with_using<'a, N>( &'a self, vocabulary: &'a mut N, generator: &'a mut impl Generator<N>, loader: &'a impl Loader, options: Options<Iri>, ) -> FlattenResult<Iri, N::BlankId> where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash { ... } async fn flatten_with<'a, N>( &'a self, vocabulary: &'a mut N, generator: &'a mut impl Generator<N>, loader: &'a impl Loader, ) -> FlattenResult<Iri, N::BlankId> where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash { ... } async fn flatten_using<'a>( &'a self, generator: &'a mut impl Generator, loader: &'a impl Loader, options: Options<Iri>, ) -> FlattenResult<Iri, BlankIdBuf> where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash { ... } async fn flatten<'a>( &'a self, generator: &'a mut impl Generator, loader: &'a impl Loader, ) -> FlattenResult<Iri, BlankIdBuf> where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash { ... } async fn to_rdf_full<N, G>( &self, vocabulary: N, generator: G, loader: &impl Loader, options: Options<Iri>, warnings: impl WarningHandler<N> + WarningHandler<N>, ) -> ToRdfResult<N, G> where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: Clone + Eq + Hash, G: Generator<N> { ... } async fn to_rdf_with_using<N, G>( &self, vocabulary: N, generator: G, loader: &impl Loader, options: Options<Iri>, ) -> ToRdfResult<N, G> where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: Clone + Eq + Hash, G: Generator<N> { ... } async fn to_rdf_with<N, G>( &self, vocabulary: N, generator: G, loader: &impl Loader, ) -> ToRdfResult<N, G> where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: Clone + Eq + Hash, G: Generator<N> { ... } async fn to_rdf_using<G>( &self, generator: G, loader: &impl Loader, options: Options<Iri>, ) -> ToRdfResult<(), G> where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, G: Generator { ... } async fn to_rdf<G>( &self, generator: G, loader: &impl Loader, ) -> ToRdfResult<(), G> where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, G: Generator { ... }
}
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(&loader)
  .await
  .expect("expansion failed");

Required Methods§

Source

async fn compare_full<N>( &self, other: &Self, vocabulary: &mut N, loader: &impl Loader, options: Options<Iri>, warnings: impl WarningHandler<N> + WarningHandler<N>, ) -> CompareResult
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: Clone + Eq + Hash,

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::vocabulary::{IriVocabularyMut, IndexVocabulary};

let mut vocabulary: IndexVocabulary = 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(iri!("https://example.com/").to_owned(), "examples");
  
assert!(input1.compare_full(
  &input2,
  &mut vocabulary,
  &loader,
  Options::default(),
  warning::PrintWith
).await.expect("comparison failed"));
Source

async fn expand_full<N>( &self, vocabulary: &mut N, loader: &impl Loader, options: Options<Iri>, warnings: impl WarningHandler<N> + WarningHandler<N>, ) -> ExpandResult<Iri, N::BlankId>
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: Clone + Eq + Hash,

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::vocabulary::{IriVocabularyMut, IndexVocabulary};
// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: IndexVocabulary = 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(iri!("https://example.com/").to_owned(), "examples");

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

async fn into_document_full<'a, N>( self, vocabulary: &'a mut N, loader: &'a impl Loader, options: Options<Iri>, warnings: impl 'a + WarningHandler<N> + WarningHandler<N>, ) -> IntoDocumentResult<Iri, N::BlankId>
where N: VocabularyMut<Iri = Iri>, Iri: 'a + Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash,

Source

async fn compact_full<'a, N>( &'a self, vocabulary: &'a mut N, context: RemoteContextReference<Iri>, loader: &'a impl Loader, options: Options<Iri>, warnings: impl 'a + WarningHandler<N> + WarningHandler<N>, ) -> CompactResult
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash,

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, RemoteContextReference, warning};
use rdf_types::vocabulary::{IriVocabularyMut, IndexVocabulary};
// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: IndexVocabulary = 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 = RemoteContextReference::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(iri!("https://example.com/").to_owned(), "examples");

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

async fn flatten_full<'a, N>( &'a self, vocabulary: &'a mut N, generator: &'a mut impl Generator<N>, context: Option<RemoteContextReference<Iri>>, loader: &'a impl Loader, options: Options<Iri>, warnings: impl 'a + WarningHandler<N> + WarningHandler<N>, ) -> FlattenResult<Iri, N::BlankId>
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash,

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::vocabulary::{IriVocabularyMut, IndexVocabulary};

// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: IndexVocabulary = 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(iri!("https://example.com/").to_owned(), "examples");

let mut generator = rdf_types::generator::Blank::new();

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

Provided Methods§

Source

async fn compare_with_using<'a, N>( &'a self, other: &'a Self, vocabulary: &'a mut N, loader: &'a impl Loader, options: Options<Iri>, ) -> CompareResult
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash,

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::vocabulary::{IriVocabularyMut, IndexVocabulary};

let mut vocabulary: IndexVocabulary = 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(iri!("https://example.com/").to_owned(), "examples");
  
assert!(input1.compare_with_using(
  &input2,
  &mut vocabulary,
  &loader,
  Options::default()
).await.expect("comparison failed"));
Source

async fn compare_with<'a, N>( &'a self, other: &'a Self, vocabulary: &'a mut N, loader: &'a impl Loader, ) -> CompareResult
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash,

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::vocabulary::{IriVocabularyMut, IndexVocabulary};
use locspan::Meta;

let mut vocabulary: IndexVocabulary = 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(iri!("https://example.com/").to_owned(), "examples");
  
assert!(input1.compare_with(
  &input2,
  &mut vocabulary,
  &loader
).await.expect("comparison failed"));
Source

async fn compare_using<'a>( &'a self, other: &'a Self, loader: &'a impl Loader, options: Options<Iri>, ) -> CompareResult
where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash,

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,
  &loader,
  Options::default()
).await.expect("comparison failed"));
Source

async fn compare<'a>( &'a self, other: &'a Self, loader: &'a impl Loader, ) -> CompareResult
where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash,

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,
  &loader
).await.expect("comparison failed"));
Source

async fn expand_with_using<'a, N>( &'a self, vocabulary: &'a mut N, loader: &'a impl Loader, options: Options<Iri>, ) -> ExpandResult<Iri, N::BlankId>
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash,

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::vocabulary::{IriVocabularyMut, IndexVocabulary};
// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: IndexVocabulary = 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(iri!("https://example.com/").to_owned(), "examples");

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

async fn expand_with<'a, N>( &'a self, vocabulary: &'a mut N, loader: &'a impl Loader, ) -> ExpandResult<Iri, N::BlankId>
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash,

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::vocabulary::{IriVocabularyMut, IndexVocabulary};
// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: IndexVocabulary = 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(iri!("https://example.com/").to_owned(), "examples");

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

async fn expand_using<'a>( &'a self, loader: &'a impl Loader, options: Options<Iri>, ) -> ExpandResult<Iri, BlankIdBuf>
where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash,

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(
    &loader,
    Options::default()
  )
  .await
  .expect("expansion failed");
Source

async fn expand<'a>( &'a self, loader: &'a impl Loader, ) -> ExpandResult<Iri, BlankIdBuf>
where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash,

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(&loader)
  .await
  .expect("expansion failed");
Source

async fn into_document_with_using<'a, N>( self, vocabulary: &'a mut N, loader: &'a impl Loader, options: Options<Iri>, ) -> IntoDocumentResult<Iri, N::BlankId>
where N: VocabularyMut<Iri = Iri>, Iri: 'a + Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash,

Source

async fn into_document_with<'a, N>( self, vocabulary: &'a mut N, loader: &'a impl Loader, ) -> IntoDocumentResult<Iri, N::BlankId>
where N: VocabularyMut<Iri = Iri>, Iri: 'a + Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash,

Source

async fn into_document<'a>( self, loader: &'a impl Loader, ) -> IntoDocumentResult<Iri, BlankIdBuf>
where (): VocabularyMut<Iri = Iri>, Iri: 'a + Clone + Eq + Hash,

Source

async fn compact_with_using<'a, N>( &'a self, vocabulary: &'a mut N, context: RemoteContextReference<Iri>, loader: &'a impl Loader, options: Options<Iri>, ) -> CompactResult
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash,

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, RemoteContextReference, warning};
use rdf_types::vocabulary::{IriVocabularyMut, IndexVocabulary};
// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: IndexVocabulary = 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 = RemoteContextReference::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(iri!("https://example.com/").to_owned(), "examples");

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

async fn compact_with<'a, N>( &'a self, vocabulary: &'a mut N, context: RemoteContextReference<Iri>, loader: &'a impl Loader, ) -> CompactResult
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash,

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, RemoteContextReference, warning};
use rdf_types::vocabulary::{IriVocabularyMut, IndexVocabulary};
// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: IndexVocabulary = 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 = RemoteContextReference::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(iri!("https://example.com/").to_owned(), "examples");

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

async fn compact_using<'a>( &'a self, context: RemoteContextReference<Iri>, loader: &'a impl Loader, options: Options<Iri>, ) -> CompactResult
where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash,

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, RemoteContextReference, 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 = RemoteContextReference::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,
    &loader,
    Options::default()
  )
  .await
  .expect("compaction failed");
Source

async fn compact<'a>( &'a self, context: RemoteContextReference<Iri>, loader: &'a impl Loader, ) -> CompactResult
where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash,

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, RemoteContextReference, 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 = RemoteContextReference::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,
    &loader
  )
  .await
  .expect("compaction failed");
Source

async fn flatten_with_using<'a, N>( &'a self, vocabulary: &'a mut N, generator: &'a mut impl Generator<N>, loader: &'a impl Loader, options: Options<Iri>, ) -> FlattenResult<Iri, N::BlankId>
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash,

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::vocabulary::{IriVocabularyMut, IndexVocabulary};

// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: IndexVocabulary = 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(iri!("https://example.com/").to_owned(), "examples");

let mut generator = rdf_types::generator::Blank::new();

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

async fn flatten_with<'a, N>( &'a self, vocabulary: &'a mut N, generator: &'a mut impl Generator<N>, loader: &'a impl Loader, ) -> FlattenResult<Iri, N::BlankId>
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash,

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::vocabulary::{IriVocabularyMut, IndexVocabulary};

// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: IndexVocabulary = 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(iri!("https://example.com/").to_owned(), "examples");

let mut generator = rdf_types::generator::Blank::new();

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

async fn flatten_using<'a>( &'a self, generator: &'a mut impl Generator, loader: &'a impl Loader, options: Options<Iri>, ) -> FlattenResult<Iri, BlankIdBuf>
where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash,

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};

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();

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

async fn flatten<'a>( &'a self, generator: &'a mut impl Generator, loader: &'a impl Loader, ) -> FlattenResult<Iri, BlankIdBuf>
where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash,

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};

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();

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

async fn to_rdf_full<N, G>( &self, vocabulary: N, generator: G, loader: &impl Loader, options: Options<Iri>, warnings: impl WarningHandler<N> + WarningHandler<N>, ) -> ToRdfResult<N, G>
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: Clone + Eq + Hash, G: Generator<N>,

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::{Quad, vocabulary::{IriVocabularyMut, IndexVocabulary}};

// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: IndexVocabulary = 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(iri!("https://example.com/").to_owned(), "examples");

let mut generator = rdf_types::generator::Blank::new();

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

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

async fn to_rdf_with_using<N, G>( &self, vocabulary: N, generator: G, loader: &impl Loader, options: Options<Iri>, ) -> ToRdfResult<N, G>
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: Clone + Eq + Hash, G: Generator<N>,

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::{Quad, vocabulary::{IriVocabularyMut, IndexVocabulary}};

// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: IndexVocabulary = 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(iri!("https://example.com/").to_owned(), "examples");

let mut generator = rdf_types::generator::Blank::new();

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

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

async fn to_rdf_with<N, G>( &self, vocabulary: N, generator: G, loader: &impl Loader, ) -> ToRdfResult<N, G>
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: Clone + Eq + Hash, G: Generator<N>,

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::{Quad, vocabulary::{IriVocabularyMut, IndexVocabulary}};

// Creates the vocabulary that will map each `rdf_types::vocabulary::Index`
// to an actual `IriBuf`.
let mut vocabulary: IndexVocabulary = 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(iri!("https://example.com/").to_owned(), "examples");

let mut generator = rdf_types::generator::Blank::new();

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

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

async fn to_rdf_using<G>( &self, generator: G, loader: &impl Loader, options: Options<Iri>, ) -> ToRdfResult<(), G>
where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, G: Generator,

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();

let mut rdf = input
  .to_rdf_using(
    &mut generator,
    &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);
  }
}
Source

async fn to_rdf<G>( &self, generator: G, loader: &impl Loader, ) -> ToRdfResult<(), G>
where (): VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, G: Generator,

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();

let mut rdf = input
  .to_rdf(
    &mut generator,
    &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);
  }
}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§