Skip to main content

ApiClient

Trait ApiClient 

Source
pub trait ApiClient: Send + Sync {
    // Required methods
    fn request(
        &self,
        method: Method,
        path: &str,
        query: Option<&str>,
        body: Option<String>,
    ) -> impl Future<Output = Result<Response, ApiError>> + Send;
    fn request_stream(
        &self,
        method: Method,
        path: &str,
        query: Option<&str>,
    ) -> impl Future<Output = Result<SseStream, ApiError>> + Send;
}
Expand description

Trait for making async API requests.

Implement this for your HTTP client (e.g. a wrapper around reqwest::Client).

Required Methods§

Source

fn request( &self, method: Method, path: &str, query: Option<&str>, body: Option<String>, ) -> impl Future<Output = Result<Response, ApiError>> + Send

Source

fn request_stream( &self, method: Method, path: &str, query: Option<&str>, ) -> impl Future<Output = Result<SseStream, ApiError>> + Send

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§