pub trait HttpProvider: Send + Sync {
// Required methods
fn get<'life0, 'life1, 'async_trait, T>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where T: DeserializeOwned + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn post<'life0, 'life1, 'life2, 'async_trait, T, B>(
&'life0 self,
path: &'life1 str,
body: &'life2 B,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where T: DeserializeOwned + Send + 'async_trait,
B: Serialize + Send + Sync + ?Sized + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn put<'life0, 'life1, 'life2, 'async_trait, T, B>(
&'life0 self,
path: &'life1 str,
body: &'life2 B,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where T: DeserializeOwned + Send + 'async_trait,
B: Serialize + Send + Sync + ?Sized + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn post_binary<'life0, 'life1, 'life2, 'async_trait, B>(
&'life0 self,
path: &'life1 str,
body: &'life2 B,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where B: Serialize + Send + Sync + ?Sized + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn set_session_token(&mut self, token: Option<String>);
fn set_timeout(&mut self, timeout: Duration);
// Provided method
fn last_response_metadata(&self) -> Option<ResponseMetadata> { ... }
}
Expand description
HTTP communication abstraction trait
This trait provides a generic interface for HTTP operations, allowing for different implementations (e.g., production HTTP client, mock for testing)
Required Methods§
Sourcefn get<'life0, 'life1, 'async_trait, T>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
T: DeserializeOwned + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait, T>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
T: DeserializeOwned + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute a GET request
Sourcefn post<'life0, 'life1, 'life2, 'async_trait, T, B>(
&'life0 self,
path: &'life1 str,
body: &'life2 B,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
fn post<'life0, 'life1, 'life2, 'async_trait, T, B>( &'life0 self, path: &'life1 str, body: &'life2 B, ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
Execute a POST request with JSON body
Sourcefn put<'life0, 'life1, 'life2, 'async_trait, T, B>(
&'life0 self,
path: &'life1 str,
body: &'life2 B,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
fn put<'life0, 'life1, 'life2, 'async_trait, T, B>( &'life0 self, path: &'life1 str, body: &'life2 B, ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
Execute a PUT request with JSON body
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute a DELETE request
Sourcefn post_binary<'life0, 'life1, 'life2, 'async_trait, B>(
&'life0 self,
path: &'life1 str,
body: &'life2 B,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
fn post_binary<'life0, 'life1, 'life2, 'async_trait, B>( &'life0 self, path: &'life1 str, body: &'life2 B, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
Execute a POST request that returns binary data
Sourcefn set_session_token(&mut self, token: Option<String>)
fn set_session_token(&mut self, token: Option<String>)
Set the session token for authenticated requests
Sourcefn set_timeout(&mut self, timeout: Duration)
fn set_timeout(&mut self, timeout: Duration)
Set the request timeout
Provided Methods§
Sourcefn last_response_metadata(&self) -> Option<ResponseMetadata>
fn last_response_metadata(&self) -> Option<ResponseMetadata>
Get response metadata for the last request (optional)
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.