Trait json_ld::JsonLdProcessor
source · pub trait JsonLdProcessor<Iri>: Sized {
Show 29 methods
// Required methods
async fn compare_full<'a, N, L>(
&'a self,
other: &'a Self,
vocabulary: &'a mut N,
loader: &'a mut L,
options: Options<Iri>,
warnings: impl 'a + WarningHandler<N> + WarningHandler<N>
) -> CompareResult<Iri, L>
where N: VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri>;
async fn expand_full<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
loader: &'a mut L,
options: Options<Iri>,
warnings: impl 'a + WarningHandler<N> + WarningHandler<N>
) -> ExpandResult<Iri, N::BlankId, L>
where N: VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri>;
async fn into_document_full<'a, N, L>(
self,
vocabulary: &'a mut N,
loader: &'a mut L,
options: Options<Iri>,
warnings: impl 'a + WarningHandler<N> + WarningHandler<N>
) -> IntoDocumentResult<Iri, N::BlankId, L>
where N: VocabularyMut<Iri = Iri>,
Iri: 'a + Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri>;
async fn compact_full<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
context: RemoteContextReference<Iri>,
loader: &'a mut L,
options: Options<Iri>,
warnings: impl 'a + WarningHandler<N> + WarningHandler<N>
) -> CompactResult<Iri, L>
where N: VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri>;
async fn flatten_full<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
generator: &'a mut impl Generator<N>,
context: Option<RemoteContextReference<Iri>>,
loader: &'a mut L,
options: Options<Iri>,
warnings: impl 'a + WarningHandler<N> + WarningHandler<N>
) -> FlattenResult<Iri, N::BlankId, L>
where N: VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri>;
// Provided methods
async fn compare_with_using<'a, N, L>(
&'a self,
other: &'a Self,
vocabulary: &'a mut N,
loader: &'a mut L,
options: Options<Iri>
) -> CompareResult<Iri, L>
where N: VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn compare_with<'a, N, L>(
&'a self,
other: &'a Self,
vocabulary: &'a mut N,
loader: &'a mut L
) -> CompareResult<Iri, L>
where N: VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn compare_using<'a, L>(
&'a self,
other: &'a Self,
loader: &'a mut L,
options: Options<Iri>
) -> CompareResult<Iri, L>
where (): VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn compare<'a, L>(
&'a self,
other: &'a Self,
loader: &'a mut L
) -> CompareResult<Iri, L>
where (): VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn expand_with_using<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
loader: &'a mut L,
options: Options<Iri>
) -> ExpandResult<Iri, N::BlankId, L>
where N: VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn expand_with<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
loader: &'a mut L
) -> ExpandResult<Iri, N::BlankId, L>
where N: VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn expand_using<'a, L>(
&'a self,
loader: &'a mut L,
options: Options<Iri>
) -> ExpandResult<Iri, BlankIdBuf, L>
where (): VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn expand<'a, L>(
&'a self,
loader: &'a mut L
) -> ExpandResult<Iri, BlankIdBuf, L>
where (): VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn into_document_with_using<'a, N, L>(
self,
vocabulary: &'a mut N,
loader: &'a mut L,
options: Options<Iri>
) -> IntoDocumentResult<Iri, N::BlankId, L>
where N: VocabularyMut<Iri = Iri>,
Iri: 'a + Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn into_document_with<'a, N, L>(
self,
vocabulary: &'a mut N,
loader: &'a mut L
) -> IntoDocumentResult<Iri, N::BlankId, L>
where N: VocabularyMut<Iri = Iri>,
Iri: 'a + Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn into_document<'a, L>(
self,
loader: &'a mut L
) -> IntoDocumentResult<Iri, BlankIdBuf, L>
where (): VocabularyMut<Iri = Iri>,
Iri: 'a + Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn compact_with_using<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
context: RemoteContextReference<Iri>,
loader: &'a mut L,
options: Options<Iri>
) -> CompactResult<Iri, L>
where N: VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn compact_with<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
context: RemoteContextReference<Iri>,
loader: &'a mut L
) -> CompactResult<Iri, L>
where N: VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn compact_using<'a, L>(
&'a self,
context: RemoteContextReference<Iri>,
loader: &'a mut L,
options: Options<Iri>
) -> CompactResult<Iri, L>
where (): VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn compact<'a, L>(
&'a self,
context: RemoteContextReference<Iri>,
loader: &'a mut L
) -> CompactResult<Iri, L>
where (): VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn flatten_with_using<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
generator: &'a mut impl Generator<N>,
loader: &'a mut L,
options: Options<Iri>
) -> FlattenResult<Iri, N::BlankId, L>
where N: VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn flatten_with<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
generator: &'a mut impl Generator<N>,
loader: &'a mut L
) -> FlattenResult<Iri, N::BlankId, L>
where N: VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn flatten_using<'a, L>(
&'a self,
generator: &'a mut impl Generator,
loader: &'a mut L,
options: Options<Iri>
) -> FlattenResult<Iri, BlankIdBuf, L>
where (): VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn flatten<'a, L>(
&'a self,
generator: &'a mut impl Generator,
loader: &'a mut L
) -> FlattenResult<Iri, BlankIdBuf, L>
where (): VocabularyMut<Iri = Iri>,
Iri: Clone + Eq + Hash,
L: Loader<Iri> { ... }
async fn to_rdf_full<'a, N, G, L>(
&'a self,
vocabulary: &'a mut N,
generator: &'a mut G,
loader: &'a mut L,
options: Options<Iri>,
warnings: impl 'a + WarningHandler<N> + WarningHandler<N>
) -> ToRdfResult<'a, N, G, L>
where N: VocabularyMut<Iri = Iri>,
Iri: 'a + Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
G: Generator<N>,
L: Loader<Iri> { ... }
async fn to_rdf_with_using<'a, N, G, L>(
&'a self,
vocabulary: &'a mut N,
generator: &'a mut G,
loader: &'a mut L,
options: Options<Iri>
) -> ToRdfResult<'a, N, G, L>
where N: VocabularyMut<Iri = Iri>,
Iri: 'a + Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
G: Generator<N>,
L: Loader<Iri> { ... }
async fn to_rdf_with<'a, N, G, L>(
&'a self,
vocabulary: &'a mut N,
generator: &'a mut G,
loader: &'a mut L
) -> ToRdfResult<'a, N, G, L>
where N: VocabularyMut<Iri = Iri>,
Iri: 'a + Clone + Eq + Hash,
N::BlankId: 'a + Clone + Eq + Hash,
G: Generator<N>,
L: Loader<Iri> { ... }
async fn to_rdf_using<'a, G, L>(
&'a self,
generator: &'a mut G,
loader: &'a mut L,
options: Options<Iri>
) -> ToRdfResult<'a, (), G, L>
where (): VocabularyMut<Iri = Iri>,
Iri: 'a + Clone + Eq + Hash,
G: Generator,
L: Loader<Iri> { ... }
async fn to_rdf<'a, G, L>(
&'a self,
generator: &'a mut G,
loader: &'a mut L
) -> ToRdfResult<'a, (), G, L>
where (): VocabularyMut<Iri = Iri>,
Iri: 'a + Clone + Eq + Hash,
G: Generator,
L: Loader<Iri> { ... }
}
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 customVocabulary
._using
: allows passing customOptions
._with_using
: allows passing both a customVocabulary
and customOptions
.- no suffix: minimum parameters. No custom vocabulary:
IriBuf
andBlankIdBuf
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§
sourceasync fn compare_full<'a, N, L>(
&'a self,
other: &'a Self,
vocabulary: &'a mut N,
loader: &'a mut L,
options: Options<Iri>,
warnings: impl 'a + WarningHandler<N> + WarningHandler<N>
) -> CompareResult<Iri, L>
async fn compare_full<'a, N, L>( &'a self, other: &'a Self, vocabulary: &'a mut N, loader: &'a mut L, options: Options<Iri>, warnings: impl 'a + WarningHandler<N> + WarningHandler<N> ) -> CompareResult<Iri, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
assert!(input1.compare_full(
&input2,
&mut vocabulary,
&mut loader,
Options::default(),
warning::PrintWith
).await.expect("comparison failed"));
sourceasync fn expand_full<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
loader: &'a mut L,
options: Options<Iri>,
warnings: impl 'a + WarningHandler<N> + WarningHandler<N>
) -> ExpandResult<Iri, N::BlankId, L>
async fn expand_full<'a, N, L>( &'a self, vocabulary: &'a mut N, loader: &'a mut L, options: Options<Iri>, warnings: impl 'a + WarningHandler<N> + WarningHandler<N> ) -> ExpandResult<Iri, N::BlankId, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
let expanded = input
.expand_full(
&mut vocabulary,
&mut loader,
Options::default(),
warning::PrintWith
)
.await
.expect("expansion failed");
async fn into_document_full<'a, N, L>( self, vocabulary: &'a mut N, loader: &'a mut L, options: Options<Iri>, warnings: impl 'a + WarningHandler<N> + WarningHandler<N> ) -> IntoDocumentResult<Iri, N::BlankId, L>
sourceasync fn compact_full<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
context: RemoteContextReference<Iri>,
loader: &'a mut L,
options: Options<Iri>,
warnings: impl 'a + WarningHandler<N> + WarningHandler<N>
) -> CompactResult<Iri, L>
async fn compact_full<'a, N, L>( &'a self, vocabulary: &'a mut N, context: RemoteContextReference<Iri>, loader: &'a mut L, options: Options<Iri>, warnings: impl 'a + WarningHandler<N> + WarningHandler<N> ) -> CompactResult<Iri, L>
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(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");
sourceasync fn flatten_full<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
generator: &'a mut impl Generator<N>,
context: Option<RemoteContextReference<Iri>>,
loader: &'a mut L,
options: Options<Iri>,
warnings: impl 'a + WarningHandler<N> + WarningHandler<N>
) -> FlattenResult<Iri, N::BlankId, L>
async fn flatten_full<'a, N, L>( &'a self, vocabulary: &'a mut N, generator: &'a mut impl Generator<N>, context: Option<RemoteContextReference<Iri>>, loader: &'a mut L, options: Options<Iri>, warnings: impl 'a + WarningHandler<N> + WarningHandler<N> ) -> FlattenResult<Iri, N::BlankId, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
let mut generator = rdf_types::generator::Blank::new();
let nodes = input
.flatten_full(
&mut vocabulary,
&mut generator,
None,
&mut loader,
Options::default(),
warning::PrintWith
)
.await
.expect("flattening failed");
Provided Methods§
sourceasync fn compare_with_using<'a, N, L>(
&'a self,
other: &'a Self,
vocabulary: &'a mut N,
loader: &'a mut L,
options: Options<Iri>
) -> CompareResult<Iri, L>
async fn compare_with_using<'a, N, L>( &'a self, other: &'a Self, vocabulary: &'a mut N, loader: &'a mut L, options: Options<Iri> ) -> CompareResult<Iri, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
assert!(input1.compare_with_using(
&input2,
&mut vocabulary,
&mut loader,
Options::default()
).await.expect("comparison failed"));
sourceasync fn compare_with<'a, N, L>(
&'a self,
other: &'a Self,
vocabulary: &'a mut N,
loader: &'a mut L
) -> CompareResult<Iri, L>
async fn compare_with<'a, N, L>( &'a self, other: &'a Self, vocabulary: &'a mut N, loader: &'a mut L ) -> CompareResult<Iri, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
assert!(input1.compare_with(
&input2,
&mut vocabulary,
&mut loader
).await.expect("comparison failed"));
sourceasync fn compare_using<'a, L>(
&'a self,
other: &'a Self,
loader: &'a mut L,
options: Options<Iri>
) -> CompareResult<Iri, L>
async fn compare_using<'a, L>( &'a self, other: &'a Self, loader: &'a mut L, options: Options<Iri> ) -> CompareResult<Iri, L>
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"));
sourceasync fn compare<'a, L>(
&'a self,
other: &'a Self,
loader: &'a mut L
) -> CompareResult<Iri, L>
async fn compare<'a, L>( &'a self, other: &'a Self, loader: &'a mut L ) -> CompareResult<Iri, L>
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"));
sourceasync fn expand_with_using<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
loader: &'a mut L,
options: Options<Iri>
) -> ExpandResult<Iri, N::BlankId, L>
async fn expand_with_using<'a, N, L>( &'a self, vocabulary: &'a mut N, loader: &'a mut L, options: Options<Iri> ) -> ExpandResult<Iri, N::BlankId, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
let expanded = input
.expand_with_using(
&mut vocabulary,
&mut loader,
Options::default()
)
.await
.expect("expansion failed");
sourceasync fn expand_with<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
loader: &'a mut L
) -> ExpandResult<Iri, N::BlankId, L>
async fn expand_with<'a, N, L>( &'a self, vocabulary: &'a mut N, loader: &'a mut L ) -> ExpandResult<Iri, N::BlankId, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
let expanded = input
.expand_with(
&mut vocabulary,
&mut loader
)
.await
.expect("expansion failed");
sourceasync fn expand_using<'a, L>(
&'a self,
loader: &'a mut L,
options: Options<Iri>
) -> ExpandResult<Iri, BlankIdBuf, L>
async fn expand_using<'a, L>( &'a self, loader: &'a mut L, options: Options<Iri> ) -> ExpandResult<Iri, BlankIdBuf, L>
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");
sourceasync fn expand<'a, L>(
&'a self,
loader: &'a mut L
) -> ExpandResult<Iri, BlankIdBuf, L>
async fn expand<'a, L>( &'a self, loader: &'a mut L ) -> ExpandResult<Iri, BlankIdBuf, L>
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");
async fn into_document_with_using<'a, N, L>( self, vocabulary: &'a mut N, loader: &'a mut L, options: Options<Iri> ) -> IntoDocumentResult<Iri, N::BlankId, L>
async fn into_document_with<'a, N, L>( self, vocabulary: &'a mut N, loader: &'a mut L ) -> IntoDocumentResult<Iri, N::BlankId, L>
async fn into_document<'a, L>( self, loader: &'a mut L ) -> IntoDocumentResult<Iri, BlankIdBuf, L>
sourceasync fn compact_with_using<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
context: RemoteContextReference<Iri>,
loader: &'a mut L,
options: Options<Iri>
) -> CompactResult<Iri, L>
async fn compact_with_using<'a, N, L>( &'a self, vocabulary: &'a mut N, context: RemoteContextReference<Iri>, loader: &'a mut L, options: Options<Iri> ) -> CompactResult<Iri, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
let compact = input
.compact_with_using(
&mut vocabulary,
context,
&mut loader,
Options::default()
)
.await
.expect("compaction failed");
sourceasync fn compact_with<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
context: RemoteContextReference<Iri>,
loader: &'a mut L
) -> CompactResult<Iri, L>
async fn compact_with<'a, N, L>( &'a self, vocabulary: &'a mut N, context: RemoteContextReference<Iri>, loader: &'a mut L ) -> CompactResult<Iri, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
let compact = input
.compact_with(
&mut vocabulary,
context,
&mut loader
)
.await
.expect("compaction failed");
sourceasync fn compact_using<'a, L>(
&'a self,
context: RemoteContextReference<Iri>,
loader: &'a mut L,
options: Options<Iri>
) -> CompactResult<Iri, L>
async fn compact_using<'a, L>( &'a self, context: RemoteContextReference<Iri>, loader: &'a mut L, options: Options<Iri> ) -> CompactResult<Iri, L>
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,
&mut loader,
Options::default()
)
.await
.expect("compaction failed");
sourceasync fn compact<'a, L>(
&'a self,
context: RemoteContextReference<Iri>,
loader: &'a mut L
) -> CompactResult<Iri, L>
async fn compact<'a, L>( &'a self, context: RemoteContextReference<Iri>, loader: &'a mut L ) -> CompactResult<Iri, L>
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,
&mut loader
)
.await
.expect("compaction failed");
sourceasync fn flatten_with_using<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
generator: &'a mut impl Generator<N>,
loader: &'a mut L,
options: Options<Iri>
) -> FlattenResult<Iri, N::BlankId, L>
async fn flatten_with_using<'a, N, L>( &'a self, vocabulary: &'a mut N, generator: &'a mut impl Generator<N>, loader: &'a mut L, options: Options<Iri> ) -> FlattenResult<Iri, N::BlankId, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
let mut generator = rdf_types::generator::Blank::new();
let nodes = input
.flatten_with_using(
&mut vocabulary,
&mut generator,
&mut loader,
Options::default()
)
.await
.expect("flattening failed");
sourceasync fn flatten_with<'a, N, L>(
&'a self,
vocabulary: &'a mut N,
generator: &'a mut impl Generator<N>,
loader: &'a mut L
) -> FlattenResult<Iri, N::BlankId, L>
async fn flatten_with<'a, N, L>( &'a self, vocabulary: &'a mut N, generator: &'a mut impl Generator<N>, loader: &'a mut L ) -> FlattenResult<Iri, N::BlankId, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
let mut generator = rdf_types::generator::Blank::new();
let nodes = input
.flatten_with(
&mut vocabulary,
&mut generator,
&mut loader
)
.await
.expect("flattening failed");
sourceasync fn flatten_using<'a, L>(
&'a self,
generator: &'a mut impl Generator,
loader: &'a mut L,
options: Options<Iri>
) -> FlattenResult<Iri, BlankIdBuf, L>
async fn flatten_using<'a, L>( &'a self, generator: &'a mut impl Generator, loader: &'a mut L, options: Options<Iri> ) -> FlattenResult<Iri, BlankIdBuf, L>
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,
&mut loader,
Options::default()
)
.await
.expect("flattening failed");
sourceasync fn flatten<'a, L>(
&'a self,
generator: &'a mut impl Generator,
loader: &'a mut L
) -> FlattenResult<Iri, BlankIdBuf, L>
async fn flatten<'a, L>( &'a self, generator: &'a mut impl Generator, loader: &'a mut L ) -> FlattenResult<Iri, BlankIdBuf, L>
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,
&mut loader
)
.await
.expect("flattening failed");
sourceasync fn to_rdf_full<'a, N, G, L>(
&'a self,
vocabulary: &'a mut N,
generator: &'a mut G,
loader: &'a mut L,
options: Options<Iri>,
warnings: impl 'a + WarningHandler<N> + WarningHandler<N>
) -> ToRdfResult<'a, N, G, L>
async fn to_rdf_full<'a, N, G, L>( &'a self, vocabulary: &'a mut N, generator: &'a mut G, loader: &'a mut L, options: Options<Iri>, warnings: impl 'a + WarningHandler<N> + WarningHandler<N> ) -> ToRdfResult<'a, N, G, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
let mut generator = rdf_types::generator::Blank::new();
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() {
// ...
}
sourceasync fn to_rdf_with_using<'a, N, G, L>(
&'a self,
vocabulary: &'a mut N,
generator: &'a mut G,
loader: &'a mut L,
options: Options<Iri>
) -> ToRdfResult<'a, N, G, L>
async fn to_rdf_with_using<'a, N, G, L>( &'a self, vocabulary: &'a mut N, generator: &'a mut G, loader: &'a mut L, options: Options<Iri> ) -> ToRdfResult<'a, N, G, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
let mut generator = rdf_types::generator::Blank::new();
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() {
// ...
}
sourceasync fn to_rdf_with<'a, N, G, L>(
&'a self,
vocabulary: &'a mut N,
generator: &'a mut G,
loader: &'a mut L
) -> ToRdfResult<'a, N, G, L>
async fn to_rdf_with<'a, N, G, L>( &'a self, vocabulary: &'a mut N, generator: &'a mut G, loader: &'a mut L ) -> ToRdfResult<'a, N, G, L>
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(vocabulary.insert(iri!("https://example.com/")), "examples");
let mut generator = rdf_types::generator::Blank::new();
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() {
// ...
}
sourceasync fn to_rdf_using<'a, G, L>(
&'a self,
generator: &'a mut G,
loader: &'a mut L,
options: Options<Iri>
) -> ToRdfResult<'a, (), G, L>
async fn to_rdf_using<'a, G, L>( &'a self, generator: &'a mut G, loader: &'a mut L, options: Options<Iri> ) -> ToRdfResult<'a, (), G, L>
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,
&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);
}
}
sourceasync fn to_rdf<'a, G, L>(
&'a self,
generator: &'a mut G,
loader: &'a mut L
) -> ToRdfResult<'a, (), G, L>
async fn to_rdf<'a, G, L>( &'a self, generator: &'a mut G, loader: &'a mut L ) -> ToRdfResult<'a, (), G, L>
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,
&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);
}
}