Struct json_ld::RemoteDocument
source · [−]pub struct RemoteDocument<D> { /* private fields */ }
Expand description
Remote JSON-LD document.
Represent a document located at a given base URL.
This is the result of loading a document with Loader::load
.
It is a simple wrapper that Deref
to the underlying document while remembering its
base URL.
Example
use static_iref::*;
use async_std::task;
use serde_json::Value;
use json_ld::{
Loader,
FsLoader,
RemoteDocument
};
// Prepare the loader.
let mut loader = FsLoader::<Value>::new(|s| serde_json::from_str(s));
loader.mount(iri!("https://w3c.github.io/json-ld-api"), "json-ld-api");
// Load the remote document.
let url = iri!("https://w3c.github.io/json-ld-api/tests/expand-manifest.jsonld");
let doc: RemoteDocument<Value> = task::block_on(loader.load(url)).unwrap();
Implementations
Create a new remote document from the document contents and base URL.
Consume the remote document and return the inner document.
Trait Implementations
A Remote document is a document.
fn expand_with<'a, C: 'a + ContextMut<T> + Send + Sync, L: 'a + Loader + Send + Sync>(
&'a self,
base_url: Option<Iri<'_>>,
context: &'a C,
loader: &'a mut L,
options: Options
) -> BoxFuture<'a, ExpansionResult<T, Self::Json>> where
D::Json: JsonExpand,
C::LocalContext: From<L::Output> + From<Self::Json>,
L::Output: Into<Self::Json>,
T: 'a + Send + Sync,
fn expand_with<'a, C: 'a + ContextMut<T> + Send + Sync, L: 'a + Loader + Send + Sync>(
&'a self,
base_url: Option<Iri<'_>>,
context: &'a C,
loader: &'a mut L,
options: Options
) -> BoxFuture<'a, ExpansionResult<T, Self::Json>> where
D::Json: JsonExpand,
C::LocalContext: From<L::Output> + From<Self::Json>,
L::Output: Into<Self::Json>,
T: 'a + Send + Sync,
Expand the document with a custom base URL, initial context, document loader and expansion options. Read more
fn expand<'a, C: 'a + ContextMut<T>, L: Loader>(
&'a self,
loader: &'a mut L
) -> BoxFuture<'a, ExpansionResult<T, Self::Json>> where
Self: Send + Sync,
Self::Json: JsonExpand,
C: Send + Sync,
C::LocalContext: From<L::Output> + From<Self::Json>,
L: Send + Sync,
L::Output: Into<Self::Json>,
T: 'a + Send + Sync,
fn expand<'a, C: 'a + ContextMut<T>, L: Loader>(
&'a self,
loader: &'a mut L
) -> BoxFuture<'a, ExpansionResult<T, Self::Json>> where
Self: Send + Sync,
Self::Json: JsonExpand,
C: Send + Sync,
C::LocalContext: From<L::Output> + From<Self::Json>,
L: Send + Sync,
L::Output: Into<Self::Json>,
T: 'a + Send + Sync,
Expand the document. Read more
fn compact_with<'a, K: JsonFrom<Self::Json>, C: ContextMutProxy<T>, L: Loader, M1, M2>(
&'a self,
base_url: Option<Iri<'a>>,
context: &'a C,
loader: &'a mut L,
options: Options,
meta_context: M1,
meta_document: M2
) -> BoxFuture<'a, Result<K, Error>> where
Self: Sync,
Self::Json: JsonExpand + JsonSrc,
T: 'a + Send + Sync,
K: JsonFrom<<C::Target as Context<T>>::LocalContext>,
C: AsJson<<C::Target as Context<T>>::LocalContext, K> + Send + Sync,
<C::Target as Context<T>>::LocalContext: JsonSrc + From<L::Output> + From<Self::Json>,
C::Target: Send + Sync,
L: 'a + Send + Sync,
M1: 'a + Clone + Send + Sync + Fn(Option<&<<C::Target as Context<T>>::LocalContext as Json>::MetaData>) -> K::MetaData,
M2: 'a + Clone + Send + Sync + Fn(Option<&<Self::Json as Json>::MetaData>) -> K::MetaData,
L::Output: Into<Self::Json>,
fn compact_with<'a, K: JsonFrom<Self::Json>, C: ContextMutProxy<T>, L: Loader, M1, M2>(
&'a self,
base_url: Option<Iri<'a>>,
context: &'a C,
loader: &'a mut L,
options: Options,
meta_context: M1,
meta_document: M2
) -> BoxFuture<'a, Result<K, Error>> where
Self: Sync,
Self::Json: JsonExpand + JsonSrc,
T: 'a + Send + Sync,
K: JsonFrom<<C::Target as Context<T>>::LocalContext>,
C: AsJson<<C::Target as Context<T>>::LocalContext, K> + Send + Sync,
<C::Target as Context<T>>::LocalContext: JsonSrc + From<L::Output> + From<Self::Json>,
C::Target: Send + Sync,
L: 'a + Send + Sync,
M1: 'a + Clone + Send + Sync + Fn(Option<&<<C::Target as Context<T>>::LocalContext as Json>::MetaData>) -> K::MetaData,
M2: 'a + Clone + Send + Sync + Fn(Option<&<Self::Json as Json>::MetaData>) -> K::MetaData,
L::Output: Into<Self::Json>,
Compact the document with a custom base URL, context, document loader and options. Read more
fn compact<'a, C: ContextMutProxy<T> + AsJson<Self::Json, Self::Json>, L: Loader>(
&'a self,
context: &'a C,
loader: &'a mut L
) -> BoxFuture<'a, Result<Self::Json, Error>> where
Self: Sync,
Self::Json: JsonFrom<Self::Json> + JsonExpand + JsonSrc + From<L::Output>,
<Self::Json as Json>::MetaData: Default,
T: 'a + Send + Sync,
C::Target: Context<T, LocalContext = Self::Json>,
C: Send + Sync,
C::Target: Send + Sync,
L: 'a + Send + Sync,
L::Output: Into<Self::Json>,
fn compact<'a, C: ContextMutProxy<T> + AsJson<Self::Json, Self::Json>, L: Loader>(
&'a self,
context: &'a C,
loader: &'a mut L
) -> BoxFuture<'a, Result<Self::Json, Error>> where
Self: Sync,
Self::Json: JsonFrom<Self::Json> + JsonExpand + JsonSrc + From<L::Output>,
<Self::Json as Json>::MetaData: Default,
T: 'a + Send + Sync,
C::Target: Context<T, LocalContext = Self::Json>,
C: Send + Sync,
C::Target: Send + Sync,
L: 'a + Send + Sync,
L::Output: Into<Self::Json>,
Compact the document.
Auto Trait Implementations
impl<D> RefUnwindSafe for RemoteDocument<D> where
D: RefUnwindSafe,
impl<D> Send for RemoteDocument<D> where
D: Send,
impl<D> Sync for RemoteDocument<D> where
D: Sync,
impl<D> Unpin for RemoteDocument<D> where
D: Unpin,
impl<D> UnwindSafe for RemoteDocument<D> where
D: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more