Struct json_ld_core::loader::RemoteDocument
source · pub struct RemoteDocument<I = IriIndex, M = Location<I>, T = Value<M>> { /* private fields */ }
Expand description
Remote document.
Stores the content of a loaded remote document along with its original URL.
Implementations§
source§impl<I, M, T> RemoteDocument<I, M, T>
impl<I, M, T> RemoteDocument<I, M, T>
sourcepub fn new(
url: Option<I>,
content_type: Option<Mime>,
document: Meta<T, M>
) -> Self
pub fn new( url: Option<I>, content_type: Option<Mime>, document: Meta<T, M> ) -> Self
Creates a new remote document.
url
is the final URL of the loaded document, after eventual
redirection.
content_type
is the HTTP Content-Type
header value of the loaded
document, exclusive of any optional parameters.
sourcepub fn new_full(
url: Option<I>,
content_type: Option<Mime>,
context_url: Option<I>,
profile: HashSet<Profile<I>>,
document: Meta<T, M>
) -> Self
pub fn new_full( url: Option<I>, content_type: Option<Mime>, context_url: Option<I>, profile: HashSet<Profile<I>>, document: Meta<T, M> ) -> Self
Creates a new remote document.
url
is the final URL of the loaded document, after eventual
redirection.
content_type
is the HTTP Content-Type
header value of the loaded
document, exclusive of any optional parameters.
context_url
is the value of the HTTP Link Header
RFC 8288 using the
http://www.w3.org/ns/json-ld#context
link relation in the response,
if any.
profile
is the value of any profile parameter retrieved as part of the
original contentType.
sourcepub fn map<U, N>(
self,
f: impl Fn(Meta<T, M>) -> Meta<U, N>
) -> RemoteDocument<I, N, U>
pub fn map<U, N>( self, f: impl Fn(Meta<T, M>) -> Meta<U, N> ) -> RemoteDocument<I, N, U>
Maps the content of the remote document.
sourcepub fn try_map<U, N, E>(
self,
f: impl Fn(Meta<T, M>) -> Result<Meta<U, N>, E>
) -> Result<RemoteDocument<I, N, U>, E>
pub fn try_map<U, N, E>( self, f: impl Fn(Meta<T, M>) -> Result<Meta<U, N>, E> ) -> Result<RemoteDocument<I, N, U>, E>
Tries to map the content of the remote document.
sourcepub fn url(&self) -> Option<&I>
pub fn url(&self) -> Option<&I>
Returns a reference to the final URL of the loaded document, after eventual redirection.
sourcepub fn content_type(&self) -> Option<&Mime>
pub fn content_type(&self) -> Option<&Mime>
Returns the HTTP Content-Type
header value of the loaded document,
exclusive of any optional parameters.
sourcepub fn context_url(&self) -> Option<&I>
pub fn context_url(&self) -> Option<&I>
Returns the value of the HTTP Link Header
RFC 8288 using the
http://www.w3.org/ns/json-ld#context
link relation in the response,
if any.
If the response’s Content-Type
is application/ld+json
, the HTTP
Link Header
is ignored. If multiple HTTP Link Headers
using the
http://www.w3.org/ns/json-ld#context
link relation are found, the
loader fails with a multiple context link headers
error.
sourcepub fn into_document(self) -> Meta<T, M>
pub fn into_document(self) -> Meta<T, M>
Drops the original URL and returns the content of the document.