use crate::loader::{Loader, LoadingResult};
use jsonld_syntax::native_stack::Recursion;
use rdfx::vocabulary::IriVocabularyMut;
use std::{future::Future, hash::Hash};
pub trait Dereference: Loader {
fn dereference<V>(&self, vocabulary: &mut V, url: V::Iri) -> impl Future<Output = LoadingResult<V::Iri, Self::Error>>
where
V: IriVocabularyMut,
V::Iri: Clone + Eq + Hash;
}
impl<L: Loader + ?Sized> Dereference for L {
fn dereference<V>(&self, vocabulary: &mut V, url: V::Iri) -> impl Future<Output = LoadingResult<V::Iri, Self::Error>>
where
V: IriVocabularyMut,
V::Iri: Clone + Eq + Hash,
{
#[expect(clippy::disallowed_methods, reason = "the one guarded invocation of a loader every algorithm goes through")]
let loading = self.load_with(vocabulary, url);
Recursion::new(loading)
}
}