Skip to main content

RemoteDocument

Struct RemoteDocument 

Source
pub struct RemoteDocument<I = Iri<String>, T = Value> {
    pub url: Option<I>,
    pub content_type: Option<MediaTypeBuf>,
    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<MediaTypeBuf>

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

Profiles advertised by the document’s media type.

§document: T

The retrieved document.

Implementations§

Source§

impl<I, T> RemoteDocument<I, T>

Source

pub fn new( url: Option<I>, content_type: Option<MediaTypeBuf>, document: T, ) -> RemoteDocument<I, T>

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<MediaTypeBuf>, context_url: Option<I>, profile: HashSet<Profile<I>>, document: T, ) -> RemoteDocument<I, T>

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.

§Errors

Returns whatever f returns for the contained 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<&MediaTypeBuf>

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.

Source§

impl<I> RemoteDocument<I>

Source

pub fn from_value( url: Option<I>, content_type: Option<MediaTypeBuf>, document: impl Into<Value>, ) -> RemoteDocument<I>

Creates a remote document from any value convertible into a jstrict::Value.

With the serde_json feature enabled, this also accepts serde_json::Value thanks to the From<serde_json::Value> implementation provided by jstrict.

Trait Implementations§

Source§

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

Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

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

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<Iri> Expand<Iri> for RemoteDocument<Iri>

A remote document knows where it comes from: its own URL is used as default base URL, so relative IRI references resolve as they would for a consumer fetching the document.

Source§

fn default_base_url(&self) -> Option<&Iri>

Returns the base URL the document is expanded against when none is given explicitly, as in Expand::expand and Expand::expand_with. Read more
Source§

async fn expand_full<N, L, W>( &self, vocabulary: &mut N, context: Context<Iri, N::BlankId>, base_url: Option<&Iri>, loader: &L, options: Options, warnings_handler: W, ) -> ExpansionResult<Iri, N::BlankId, L::Error>
where N: VocabularyMut<Iri = Iri>, Iri: Clone + Eq + Hash, N::BlankId: Clone + Eq + Hash, L: Loader, W: WarningHandler<N>,

Expands the document, controlling every parameter of the algorithm. Read more
Source§

async fn expand_with<'a, N, L>( &'a self, vocabulary: &'a mut N, loader: &'a L, ) -> ExpansionResult<Iri, N::BlankId, L::Error>
where N: VocabularyMut<Iri = Iri>, Iri: 'a + Clone + Eq + Hash, N::BlankId: 'a + Clone + Eq + Hash, L: Loader,

Expands the document, interpreting identifiers with the given vocabulary. Read more
Source§

async fn expand<'a, L>( &'a self, loader: &'a L, ) -> ExpansionResult<Iri, BlankIdBuf, L::Error>
where (): VocabularyMut<Iri = Iri>, Iri: 'a + Clone + Eq + Hash, L: Loader,

Expands the document, keeping identifiers as IriBuf and BlankIdBuf values instead of interning them in a vocabulary. Read more

Auto Trait Implementations§

§

impl<I, T> Freeze for RemoteDocument<I, T>
where Option<I>: Freeze, HashSet<Profile<I>>: Freeze, T: Freeze,

§

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

§

impl<I, T> Send for RemoteDocument<I, T>
where Option<I>: Send, HashSet<Profile<I>>: Send, T: Send,

§

impl<I, T> Sync for RemoteDocument<I, T>
where Option<I>: Sync, HashSet<Profile<I>>: Sync, T: Sync,

§

impl<I, T> Unpin for RemoteDocument<I, T>
where Option<I>: Unpin, HashSet<Profile<I>>: Unpin, T: Unpin,

§

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

§

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

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> 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> BorrowUnordered for T

Source§

fn as_unordered(&self) -> &Unordered<T>

Views this value as an Unordered reference.
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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

type Error = !

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>
where T: Sized,