pub struct RemoteDocument<I = IriBuf, T = Value> {
pub url: Option<I>,
pub content_type: Option<Mime>,
pub context_url: Option<I>,
pub profile: HashSet<Profile<I>>,
pub document: T,
}
Expand description
Remote document.
Stores the content of a loaded remote document along with its original URL.
Fields§
§url: Option<I>
The final URL of the loaded document, after eventual redirection.
content_type: Option<Mime>
The HTTP Content-Type
header value of the loaded document, exclusive
of any optional parameters.
context_url: Option<I>
If available, 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 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.
profile: HashSet<Profile<I>>
§document: T
The retrieved document.
Implementations§
Source§impl<I, T> RemoteDocument<I, T>
impl<I, T> RemoteDocument<I, T>
Sourcepub fn new(url: Option<I>, content_type: Option<Mime>, document: T) -> Self
pub fn new(url: Option<I>, content_type: Option<Mime>, document: T) -> 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: T,
) -> Self
pub fn new_full( url: Option<I>, content_type: Option<Mime>, context_url: Option<I>, profile: HashSet<Profile<I>>, document: T, ) -> 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>(self, f: impl Fn(T) -> U) -> RemoteDocument<I, U>
pub fn map<U>(self, f: impl Fn(T) -> U) -> RemoteDocument<I, U>
Maps the content of the remote document.
Sourcepub fn try_map<U, E>(
self,
f: impl Fn(T) -> Result<U, E>,
) -> Result<RemoteDocument<I, U>, E>
pub fn try_map<U, E>( self, f: impl Fn(T) -> Result<U, E>, ) -> Result<RemoteDocument<I, U>, E>
Tries to map the content of the remote document.
Sourcepub fn map_iris<J>(self, f: impl FnMut(I) -> J) -> RemoteDocument<J, T>
pub fn map_iris<J>(self, f: impl FnMut(I) -> J) -> RemoteDocument<J, T>
Maps all the IRIs.
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 document_mut(&mut self) -> &mut T
pub fn document_mut(&mut self) -> &mut T
Returns a mutable reference to the content of the document.
Sourcepub fn into_document(self) -> T
pub fn into_document(self) -> T
Drops the original URL and returns the content of the document.
Trait Implementations§
Source§impl<I, B> Borrow<RemoteDocument<I>> for Document<I, B>
impl<I, B> Borrow<RemoteDocument<I>> for Document<I, B>
Source§fn borrow(&self) -> &RemoteDocument<I>
fn borrow(&self) -> &RemoteDocument<I>
Source§impl<I: Clone, T: Clone> Clone for RemoteDocument<I, T>
impl<I: Clone, T: Clone> Clone for RemoteDocument<I, T>
Source§fn clone(&self) -> RemoteDocument<I, T>
fn clone(&self) -> RemoteDocument<I, T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more