Struct RemoteDocument

Source
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>

Source

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.

Source

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.

Source

pub fn map<U>(self, f: impl Fn(T) -> U) -> RemoteDocument<I, U>

Maps the content of the remote document.

Source

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.

Source

pub fn map_iris<J>(self, f: impl FnMut(I) -> J) -> RemoteDocument<J, T>
where J: Eq + Hash,

Maps all the IRIs.

Source

pub fn url(&self) -> Option<&I>

Returns a reference to the final URL of the loaded document, after eventual redirection.

Source

pub fn content_type(&self) -> Option<&Mime>

Returns the HTTP Content-Type header value of the loaded document, exclusive of any optional parameters.

Source

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.

Source

pub fn document(&self) -> &T

Returns a reference to the content of the document.

Source

pub fn document_mut(&mut self) -> &mut T

Returns a mutable reference to the content of the document.

Source

pub fn into_document(self) -> T

Drops the original URL and returns the content of the document.

Source

pub fn into_url(self) -> Option<I>

Drops the content and returns the original URL of the document.

Source

pub fn set_url(&mut self, url: Option<I>)

Sets the URL of the document.

Trait Implementations§

Source§

impl<I, B> Borrow<RemoteDocument<I>> for Document<I, B>

Source§

fn borrow(&self) -> &RemoteDocument<I>

Immutably borrows from an owned value. Read more
Source§

impl<I: Clone, T: Clone> Clone for RemoteDocument<I, T>

Source§

fn clone(&self) -> RemoteDocument<I, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I: Debug, T: Debug> Debug for RemoteDocument<I, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<I, T> Freeze for RemoteDocument<I, T>
where T: Freeze, I: Freeze,

§

impl<I, T> RefUnwindSafe for RemoteDocument<I, T>

§

impl<I, T> Send for RemoteDocument<I, T>
where T: Send, I: Send,

§

impl<I, T> Sync for RemoteDocument<I, T>
where T: Sync, I: Sync,

§

impl<I, T> Unpin for RemoteDocument<I, T>
where T: Unpin, I: Unpin,

§

impl<I, T> UnwindSafe for RemoteDocument<I, T>
where T: UnwindSafe, I: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> At for T

Source§

fn at<M>(self, metadata: M) -> Meta<T, M>

Wraps self inside a Meta<Self, M> using the given metadata. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> BorrowStripped for T

Source§

fn stripped(&self) -> &Stripped<T>

Source§

impl<T> BorrowUnordered for T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, C> FromWithContext<T, C> for T

Source§

fn from_with(value: T, _context: &C) -> T

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U, C> IntoWithContext<U, C> for T
where U: FromWithContext<T, C>,

Source§

fn into_with(self, context: &C) -> U

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U, C> TryFromWithContext<U, C> for T
where U: IntoWithContext<T, C>,

Source§

type Error = Infallible

Source§

fn try_from_with( value: U, context: &C, ) -> Result<T, <T as TryFromWithContext<U, C>>::Error>

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U, C> TryIntoWithContext<U, C> for T
where U: TryFromWithContext<T, C>,

Source§

type Error = <U as TryFromWithContext<T, C>>::Error

Source§

fn try_into_with( self, context: &C, ) -> Result<U, <T as TryIntoWithContext<U, C>>::Error>

Source§

impl<T> WithContext for T
where T: ?Sized,

Source§

fn with<C>(&self, context: C) -> Contextual<&T, C>

Source§

fn into_with<C>(self, context: C) -> Contextual<T, C>