Skip to main content

HttpsClient

Struct HttpsClient 

Source
pub struct HttpsClient { /* private fields */ }
Available on crate feature client only.
Expand description

HTTPS Trust Tasks client.

Implementations§

Source§

impl HttpsClient

Source

pub fn builder() -> HttpsClientBuilder

Start a new builder.

Source

pub async fn send<Req>( &self, request: TrustTask<Req>, ) -> Result<TrustTask<Req::Response>, ClientError>

Send a typed Trust Task request to the configured server and receive a typed response.

The client:

  1. Populates issuer / recipient on the outbound document from the configured VIDs if they are not already set.
  2. Optionally strips redundant in-band members per HttpsClientBuilder::strip_redundant_in_band.
  3. POSTs the JSON body with Authorization: Bearer <my_token> if a token is configured.
  4. On HTTP 2xx, deserialises the body as TrustTask<Req::Response> and binds it to the request (see below).
  5. On non-2xx, deserialises the body as an ErrorResponse, checks its inResponseTo.id where present, and returns it via ClientError::TrustTaskError — or, with a response verifier configured and the error not attested by it, via ClientError::UnverifiedErrorResponse.
§Response binding

A 2xx body that merely deserialises as TrustTask<Req::Response> proves nothing: it could answer a different request, be a different task type whose payload happens to be shape-compatible, come from a party that is not the configured server, or be addressed to someone else. HTTP’s request/response pairing is not a security property — a proxy, a connection-reuse bug, or anything else in the path can substitute one body for another. So four equalities are enforced before the typed response is handed back:

MemberMust equalOn failure
threadIdthe request’s threadId, or its idClientError::ResponseThreadMismatch
typethe request’s type with #responseClientError::ResponseTypeMismatch
issuerthe configured server_vidClientError::ResponseIssuerMismatch
recipientthe configured my_vidClientError::ResponseRecipientMismatch

The issuer / recipient checks are skipped for a VID the caller did not configure — there is nothing to compare against. When HttpsClientBuilder::strip_redundant_in_band is set, an absent member is accepted (the client asked for it to be stripped and the responder echoed the absence); otherwise absence is a mismatch.

On an error response, inResponseTo.id — where the responder populated it — must be the request’s id, else ClientError::ErrorResponseMismatch. It is legitimately absent under identityMismatch (SPEC §8.1 omits it), so absence is not an error.

§Naming the response

The response type is not a parameter: it is <Req as RequestPayload>::Response, which the codegen pairs with the request from the one schema. send::<grant::Payload>(req) therefore returns TrustTask<grant::Response> and nothing else, where the previous send::<Req, Resp> accepted a mismatched pair such as send::<grant::Payload, revoke::Response>(req) and turned it into a decode failure at run time.

A specification defining no success response implements no RequestPayload, so send does not compile for it — see the trait’s docs.

Auto Trait Implementations§

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

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

Source§

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

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

Source§

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

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

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