pub trait Loader: Sync {
type Error: Error + Send + Sync + 'static;
// Required method
fn load(
&self,
url: Iri<&str>,
) -> impl Future<Output = Result<RemoteDocument<IriBuf>, LoadError<Self::Error>>> + Send;
}Expand description
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:
NoLoaderdummy loader that always fail. Perfect if you are certain that the processing will not require any loading.- Standard
HashMapandBTreeMapmapping IRIs to pre-loaded documents. This way no network calls are performed and the loaded content can be trusted. FsLoaderthat 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.ReqwestLoaderactually downloading the remote documents using thereqwestlibrary. This requires thereqwestfeature to be enabled.
A loader is Sync and its Loader::load future is Send, so that the
algorithms, which hold the loader by reference across .awaits, can run
on a multi-threaded executor.
Required Associated Types§
Required Methods§
Sourcefn load(
&self,
url: Iri<&str>,
) -> impl Future<Output = Result<RemoteDocument<IriBuf>, LoadError<Self::Error>>> + Send
fn load( &self, url: Iri<&str>, ) -> impl Future<Output = Result<RemoteDocument<IriBuf>, LoadError<Self::Error>>> + Send
Loads the document behind the given IRI.
The future is Send, so that an async fn generic over its loader,
and the algorithms that invoke it, are Send whenever their other
inputs are. An implementation written as an async fn meets this when
what it holds across an .await is Send.
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<S: BuildHasher + Send + Sync> Loader for HashMap<IriBuf, RemoteDocument, S>
impl<S: BuildHasher + Send + Sync> Loader for HashMap<IriBuf, RemoteDocument, S>
Implementors§
Source§impl Loader for ReqwestLoader
Available on crate feature reqwest only.
impl Loader for ReqwestLoader
reqwest only.