Trait json_ld_core::loader::Loader
source · pub trait Loader<I = IriBuf> {
type Error;
// Required method
async fn load_with<V>(
&mut self,
vocabulary: &mut V,
url: I,
) -> LoadingResult<I, Self::Error>
where V: IriVocabularyMut<Iri = I>;
// Provided method
async fn load(&mut self, url: I) -> Result<RemoteDocument<I>, Self::Error>
where (): IriVocabulary<Iri = I> { ... }
}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.
Required Associated Types§
Required Methods§
sourceasync fn load_with<V>(
&mut self,
vocabulary: &mut V,
url: I,
) -> LoadingResult<I, Self::Error>where
V: IriVocabularyMut<Iri = I>,
async fn load_with<V>(
&mut self,
vocabulary: &mut V,
url: I,
) -> LoadingResult<I, Self::Error>where
V: IriVocabularyMut<Iri = I>,
Loads the document behind the given IRI, using the given vocabulary.
Provided Methods§
sourceasync fn load(&mut self, url: I) -> Result<RemoteDocument<I>, Self::Error>where
(): IriVocabulary<Iri = I>,
async fn load(&mut self, url: I) -> Result<RemoteDocument<I>, Self::Error>where
(): IriVocabulary<Iri = I>,
Loads the document behind the given IRI.
Object Safety§
This trait is not object safe.