[−][src]Trait json_ld::Document
JSON-LD document.
This trait represent a JSON-LD document that can be expanded into an ExpandedDocument
.
It is notabily implemented for the JsonValue
type.
Associated Types
type LocalContext: Local<T>
The type of local contexts that may appear in the document.
This will most likely be JsonValue
.
Required methods
fn base_url(&self) -> Option<Iri>
Document location, if any.
fn expand_with<'a, C: Send + Sync + ContextMut<T>, L: Send + Sync + Loader>(
&'a self,
base_url: Option<Iri>,
context: &'a C,
loader: &'a mut L,
options: Options
) -> BoxFuture<'a, Result<ExpandedDocument<T>, Error>> where
C::LocalContext: Send + Sync + From<L::Output> + From<Self::LocalContext>,
L::Output: Into<Self::LocalContext>,
T: 'a + Send + Sync,
&'a self,
base_url: Option<Iri>,
context: &'a C,
loader: &'a mut L,
options: Options
) -> BoxFuture<'a, Result<ExpandedDocument<T>, Error>> where
C::LocalContext: Send + Sync + From<L::Output> + From<Self::LocalContext>,
L::Output: Into<Self::LocalContext>,
T: 'a + Send + Sync,
Expand the document with a custom base URL, initial context, document loader and expansion options.
If you do not wish to set the base URL and expansion options yourself, the
expand
method is more appropriate.
This is an asynchronous method since expanding the context may require loading remote
ressources. It returns a boxed Future
to the result.
Provided methods
fn expand<'a, C: Send + Sync + ContextMut<T>, L: Send + Sync + Loader>(
&'a self,
context: &'a C,
loader: &'a mut L
) -> BoxFuture<'a, Result<ExpandedDocument<T>, Error>> where
C::LocalContext: Send + Sync + From<L::Output> + From<Self::LocalContext>,
L::Output: Into<Self::LocalContext>,
T: 'a + Send + Sync,
&'a self,
context: &'a C,
loader: &'a mut L
) -> BoxFuture<'a, Result<ExpandedDocument<T>, Error>> where
C::LocalContext: Send + Sync + From<L::Output> + From<Self::LocalContext>,
L::Output: Into<Self::LocalContext>,
T: 'a + Send + Sync,
Expand the document.
Uses the given initial context and the given document loader.
The default implementation is equivalent to expand_with
, but
uses the document base_url
, with the default
options.
This is an asynchronous method since expanding the context may require loading remote
ressources. It returns a boxed Future
to the result.
Example
use std_async::task; use json_ld::{Document, JsonContext, NoLoader}; // Prepare the initial context. let context = JsonContext::new(); let doc = json::parse("{ \"@context\": { \"name\": \"http://xmlns.com/foaf/0.1/name\", \"knows\": \"http://xmlns.com/foaf/0.1/knows\" }, \"@id\": \"http://timothee.haudebourg.net/\", \"name\": \"Timothée Haudebourg\", \"knows\": [ { \"name\": \"Amélie Barbe\" } ] }")?; let expanded_doc = task::block_on(doc.expand(&context, &mut NoLoader))?;
Implementations on Foreign Types
impl<T: Id> Document<T> for JsonValue
[src]
Default JSON document implementation.
type LocalContext = JsonValue
fn base_url(&self) -> Option<Iri>
[src]
Returns None
.
Use RemoteDocument
to attach a base URL to a JsonValue
document.
fn expand_with<'a, C: Send + Sync + ContextMut<T>, L: Send + Sync + Loader>(
&'a self,
base_url: Option<Iri>,
context: &'a C,
loader: &'a mut L,
options: Options
) -> BoxFuture<'a, Result<ExpandedDocument<T>, Error>> where
C::LocalContext: Send + Sync + From<L::Output> + From<JsonValue>,
L::Output: Into<JsonValue>,
T: 'a + Send + Sync,
[src]
&'a self,
base_url: Option<Iri>,
context: &'a C,
loader: &'a mut L,
options: Options
) -> BoxFuture<'a, Result<ExpandedDocument<T>, Error>> where
C::LocalContext: Send + Sync + From<L::Output> + From<JsonValue>,
L::Output: Into<JsonValue>,
T: 'a + Send + Sync,
Implementors
impl<T: Id, D: Document<T>> Document<T> for RemoteDocument<D>
[src]
A Remote document is a document.
type LocalContext = D::LocalContext
fn base_url(&self) -> Option<Iri>
[src]
fn expand_with<'a, C: Send + Sync + ContextMut<T>, L: Send + Sync + Loader>(
&'a self,
base_url: Option<Iri>,
context: &'a C,
loader: &'a mut L,
options: Options
) -> BoxFuture<'a, Result<ExpandedDocument<T>, Error>> where
C::LocalContext: Send + Sync + From<L::Output> + From<Self::LocalContext>,
L::Output: Into<Self::LocalContext>,
T: 'a + Send + Sync,
[src]
&'a self,
base_url: Option<Iri>,
context: &'a C,
loader: &'a mut L,
options: Options
) -> BoxFuture<'a, Result<ExpandedDocument<T>, Error>> where
C::LocalContext: Send + Sync + From<L::Output> + From<Self::LocalContext>,
L::Output: Into<Self::LocalContext>,
T: 'a + Send + Sync,