pub trait Loader {
// Required method
async fn load(&self, url: &Iri) -> Result<RemoteDocument, LoadError>;
// Provided method
async fn load_with<V>(
&self,
vocabulary: &mut V,
url: <V as IriVocabulary>::Iri,
) -> Result<RemoteDocument<<V as IriVocabulary>::Iri>, LoadError>
where V: IriVocabularyMut,
<V as IriVocabulary>::Iri: Clone + Eq + Hash { ... }
}
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:
NoLoader
dummy loader that always fail. Perfect if you are certain that the processing will not require any loading.- Standard
HashMap
andBTreeMap
mapping IRIs to pre-loaded documents. This way no network calls are performed and the loaded content can be trusted. FsLoader
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.ReqwestLoader
actually downloading the remote documents using thereqwest
library. This requires thereqwest
feature to be enabled.
Required Methods§
Provided Methods§
Sourceasync fn load_with<V>(
&self,
vocabulary: &mut V,
url: <V as IriVocabulary>::Iri,
) -> Result<RemoteDocument<<V as IriVocabulary>::Iri>, LoadError>
async fn load_with<V>( &self, vocabulary: &mut V, url: <V as IriVocabulary>::Iri, ) -> Result<RemoteDocument<<V as IriVocabulary>::Iri>, LoadError>
Loads the document behind the given IRI, using the given vocabulary.
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.