json_ld_core/loader/
none.rs

1use super::Loader;
2use crate::{LoadError, LoadingResult};
3use iref::Iri;
4
5/// Dummy loader.
6///
7/// A dummy loader that does not load anything.
8/// Can be useful when you know that you will never need to load remote resource.
9///
10/// Raises an `LoadingDocumentFailed` at every attempt to load a resource.
11#[derive(Debug, Default)]
12pub struct NoLoader;
13
14#[derive(Debug, thiserror::Error)]
15#[error("no loader")]
16pub struct CannotLoad;
17
18impl Loader for NoLoader {
19	#[inline(always)]
20	async fn load(&self, url: &Iri) -> LoadingResult {
21		Err(LoadError::new(url.to_owned(), CannotLoad))
22	}
23}