Skip to main content

jsonld_core/loader/
none.rs

1use super::Loader;
2use crate::{LoadError, loader::RemoteDocument};
3use iri_rs::{Iri, IriBuf};
4
5/// Loader that never loads anything.
6///
7/// Useful when the documents being processed are known not to reference any
8/// remote context. Every load attempt fails with [`CannotLoad`].
9#[derive(Debug, Default)]
10pub struct NoLoader;
11
12#[derive(Debug, thiserror::Error)]
13#[error("no loader")]
14/// Error raised by a loader that never loads anything.
15pub struct CannotLoad;
16
17impl Loader for NoLoader {
18    type Error = CannotLoad;
19
20    #[inline(always)]
21    async fn load(&self, url: Iri<&str>) -> Result<RemoteDocument<IriBuf>, LoadError<Self::Error>> {
22        Err(LoadError::new(url.into(), CannotLoad))
23    }
24}