Skip to main content

AsyncJsonLdLoader

Trait AsyncJsonLdLoader 

Source
pub trait AsyncJsonLdLoader {
    // Required method
    async fn async_load(
        &self,
        url: &Iri,
    ) -> Result<JsonLdDocument, JsonLdLoadError>;
}
Expand description

Async Document loader.

A document loader is required by most processing functions to fetch remote documents identified by an IRI. In particular, the loader is in charge of fetching all the remote contexts imported in a @context entry.

This library provides a few default loader implementations:

  • NoJsonLdLoader dummy loader that always fail. Perfect if you are certain that the processing will not require any loading.
  • Standard HashMap and BTreeMap mapping IRIs to pre-loaded documents. This way no network calls are performed and the loaded content can be trusted.
  • JsonLdFsLoader that redirecting registered IRI prefixes to a local directory on the file system. This also avoids network calls. The loaded content can be trusted as long as the file system is trusted.
  • JsonLdReqwestLoader actually downloading the remote documents using the reqwest library. This requires the reqwest feature to be enabled.

Required Methods§

Source

async fn async_load(&self, url: &Iri) -> Result<JsonLdDocument, JsonLdLoadError>

Loads the document behind the given IRI.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl AsyncJsonLdLoader for BTreeMap<IriBuf, JsonLdDocument>

Source§

impl AsyncJsonLdLoader for HashMap<IriBuf, JsonLdDocument>

Source§

impl<L: AsyncJsonLdLoader, F: FnOnce() -> L> AsyncJsonLdLoader for LazyLock<L, F>

Lazily initialized loader, e.g. a static map of pre-loaded documents.

Source§

impl<L: AsyncJsonLdLoader> AsyncJsonLdLoader for &L

Source§

impl<L: AsyncJsonLdLoader> AsyncJsonLdLoader for &mut L

Implementors§