Skip to main content

HttpClient

Trait HttpClient 

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

    // Required methods
    fn execute(
        &self,
        request: Self::Request,
        body: &[u8],
    ) -> Result<HttpRequestResultRaw, Error>;
    fn new_request(&self, url: &str) -> Self::Request;

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

The base HTTP synchronous 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: &[u8], ) -> Result<HttpRequestResultRaw, Error>

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>) -> Result<bool, Error>

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 dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl HttpClient for AppAuthDefaultClient

Available on crate feature default_client only.
Source§

impl HttpClient for NoauthDefaultClient

Available on crate feature default_client only.
Source§

impl HttpClient for TeamAuthDefaultClient

Available on crate feature default_client only.
Source§

impl HttpClient for UserAuthDefaultClient

Available on crate feature default_client only.