Skip to main content

Context

Struct Context 

Source
pub struct Context<D> { /* private fields */ }
Expand description

What every callback receives: the application’s data, the canonical origin, and the request, if there is one. Cheap to clone.

Implementations§

Source§

impl<D: Clone + Send + Sync + 'static> Context<D>

Source

pub fn data(&self) -> &D

The application’s data.

Source

pub fn origin(&self) -> &Url

The canonical origin every URI is built in.

Source

pub fn uris(&self) -> Uris

The URIs of what is registered, in the canonical origin.

Source

pub fn actor_uri(&self, kind: &str, identifier: &str) -> Result<Url, UriError>

The URI of the actor of kind with identifier.

§Errors

When no actor dispatcher is of kind, or identifier is empty for a template that needs one.

Source

pub fn key_id(&self, kind: &str, identifier: &str) -> Result<Url, UriError>

The ID of the key the actor of kind with identifier signs with; see Uris::key_id.

§Errors

As Context::actor_uri.

Source

pub fn object_uri( &self, kind: &str, values: &[(&str, &str)], ) -> Result<Url, UriError>

The URI of the object of kind with values.

§Errors

When no object dispatcher is of kind, or values do not fill its template.

Source

pub fn collection_uri( &self, kind: &str, identifier: &str, ) -> Result<Url, UriError>

The URI of the collection kind of what identifier names.

§Errors

As Context::actor_uri, for collections.

Source

pub fn inbox_uri(&self, kind: &str, identifier: &str) -> Result<Url, UriError>

The URI of the inbox of the actor of kind with identifier.

§Errors

As Context::actor_uri, for inboxes.

Source

pub fn shared_inbox_uri(&self) -> Result<Url, UriError>

The URI of the shared inbox.

§Errors

When no shared inbox is registered.

Source

pub fn is_our_host(&self, host: &str) -> bool

Whether host, with its port if it has one, is the canonical origin’s or one of its aliases.

Source

pub fn parse_uri(&self, iri: &str) -> Option<Route>

What iri is, if it is ours: on the canonical origin or an alias, and matching a registered template.

Source

pub fn parse_actor(&self, kind: &str, iri: &str) -> Option<String>

The identifier of the actor of kind that iri is, if it is one of ours: what a listener checks a Follow’s object against.

Source

pub fn parse_object(&self, kind: &str, iri: &str) -> Option<Values>

The values of the object of kind that iri is, if it is one of ours: what a listener checks an inReplyTo or a Like’s object against.

Source

pub async fn actor_keys( &self, actor: &ActorRef, ) -> Result<Vec<PublicKey>, Error>

The public keys actor publishes, from the key-pairs dispatcher; none when there is no such dispatcher.

§Errors

What the dispatcher returns.

Source

pub async fn signer(&self) -> Option<Url>

The actor who signed the request, verified: the signature is sound, made for this host and recently, and made with a key its actor publishes. None when the request is unsigned, the signature fails, there is no request, or signed fetches are not configured. Verified once per request, however often it is asked.

Source

pub async fn signing(&self) -> Signing

How the request was signed: not at all, by an actor whose signature verifies, with a key on a server Builder::blocked refuses, or with a signature that does not hold. Verified once per request, however often it is asked, and as Context::signer verifies it.

Source

pub fn query(&self) -> Option<&str>

The query of the request, if there is a request and it has one: for a dispatcher that reads parameters of its own, such as how a collection it writes itself is paged.

Source

pub fn query_value(&self, name: &str) -> Option<String>

The value of the query parameter name, decoded, if the request has it: the first, when it has it more than once.

Source

pub fn request_header(&self, name: &str) -> Option<String>

The value of the request’s header name, if it has one and it is text.

Source

pub fn set_response_header(&self, name: &str, value: Option<&str>)

Send value as the response’s header name, or no such header when it is None, in place of what Ojak would send: for a dispatcher or guard saying how the response may be cached, such as its Cache-Control and the request headers it Varys on. It applies to whatever the request is answered with, a refusal or a 404 included. A name or value that is no header is ignored.

Trait Implementations§

Source§

impl<D> Clone for Context<D>

Source§

fn clone(&self) -> Self

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

Auto Trait Implementations§

§

impl<D> !RefUnwindSafe for Context<D>

§

impl<D> !UnwindSafe for Context<D>

§

impl<D> Freeze for Context<D>

§

impl<D> Send for Context<D>
where D: Sync + Send,

§

impl<D> Sync for Context<D>
where D: Sync + Send,

§

impl<D> Unpin for Context<D>

§

impl<D> UnsafeUnpin for Context<D>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more