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§
Sourcetype Request: HttpRequest + Send
type Request: HttpRequest + Send
The concrete type of request supported by the client.
Required Methods§
Sourcefn execute(
&self,
request: Self::Request,
body: Bytes,
) -> impl Future<Output = Result<HttpRequestResultRaw, Error>> + Send
fn execute( &self, request: Self::Request, body: Bytes, ) -> impl Future<Output = Result<HttpRequestResultRaw, Error>> + Send
Make a HTTP request.
Sourcefn new_request(&self, url: &str) -> Self::Request
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§
Sourcefn update_token(
&self,
_old_token: Arc<String>,
) -> impl Future<Output = Result<bool, Error>> + Send
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.
Sourcefn team_select(&self) -> Option<&TeamSelect>
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.
impl HttpClient for AppAuthDefaultClient
default_async_client
only.type Request = ReqwestRequest
Source§impl HttpClient for NoauthDefaultClient
Available on crate feature default_async_client
only.
impl HttpClient for NoauthDefaultClient
default_async_client
only.type Request = ReqwestRequest
Source§impl HttpClient for TeamAuthDefaultClient
Available on crate feature default_async_client
only.
impl HttpClient for TeamAuthDefaultClient
default_async_client
only.type Request = ReqwestRequest
Source§impl HttpClient for UserAuthDefaultClient
Available on crate feature default_async_client
only.
impl HttpClient for UserAuthDefaultClient
default_async_client
only.type Request = ReqwestRequest
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.
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.