Trait HttpClient

Source
pub trait HttpClient: Sync {
    type Request: HttpRequest + Send;

    // Required methods
    fn execute(
        &self,
        request: Self::Request,
        body: Bytes,
    ) -> impl Future<Output = Result<HttpRequestResultRaw, Error>> + Send;
    fn new_request(&self, url: &str) -> Self::Request;

    // Provided methods
    fn update_token(
        &self,
        _old_token: Arc<String>,
    ) -> impl Future<Output = Result<bool, Error>> + Send { ... }
    fn token(&self) -> Option<Arc<String>> { ... }
    fn path_root(&self) -> Option<&str> { ... }
    fn team_select(&self) -> Option<&TeamSelect> { ... }
}
Expand description

The base HTTP asynchronous client trait.

Required Associated Types§

Source

type Request: HttpRequest + Send

The concrete type of request supported by the client.

Required Methods§

Source

fn execute( &self, request: Self::Request, body: Bytes, ) -> impl Future<Output = Result<HttpRequestResultRaw, Error>> + Send

Make a HTTP request.

Source

fn new_request(&self, url: &str) -> Self::Request

Create a new request instance for the given URL. It should be a POST request.

Provided Methods§

Source

fn update_token( &self, _old_token: Arc<String>, ) -> impl Future<Output = Result<bool, Error>> + Send

Attempt to update the current authentication token. The previously fetched token is given as a way to avoid repeat updates in case of a race. If the update is successful, return true and the current request will be retried with a newly-fetched token. Return false if authentication is not supported, or return an error if the update operation fails.

Source

fn token(&self) -> Option<Arc<String>>

The client’s current authentication token, if any.

Source

fn path_root(&self) -> Option<&str>

The currently set path root, if any.

Source

fn team_select(&self) -> Option<&TeamSelect>

The alternate user or team context currently set, if any.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl HttpClient for AppAuthDefaultClient

Available on crate feature default_async_client only.
Source§

impl HttpClient for NoauthDefaultClient

Available on crate feature default_async_client only.
Source§

impl HttpClient for TeamAuthDefaultClient

Available on crate feature default_async_client only.
Source§

impl HttpClient for UserAuthDefaultClient

Available on crate feature default_async_client only.
Source§

impl<T: HttpClient + Sync> HttpClient for T

Blanket implementation of the async interface for all sync clients. This is necessary because all the machinery is actually implemented in terms of the async client.