pub trait ContextLoader {
// Required method
fn load<'a>(
&'a mut self,
url: &'a str,
) -> Pin<Box<dyn Future<Output = Option<String>> + 'a>>;
// Provided method
fn load_val<'a>(
&'a mut self,
url: &'a str,
) -> Pin<Box<dyn Future<Output = Option<JsonLdVal>> + 'a>> { ... }
}Expand description
Hook for fetching remote JSON-LD context documents asynchronously.
Implement this trait to support @context values that are URLs. The
load method receives the URL and should return the raw JSON-LD document
content as a string, or None if the document cannot be fetched.
§Example (sync wrapper)
ⓘ
struct MyLoader;
impl ContextLoader for MyLoader {
fn load<'a>(&'a self, url: &'a str) -> Pin<Box<dyn Future<Output = Option<String>> + 'a>> {
Box::pin(async move { Some(fetch_remote(url).await) })
}
}