Skip to main content

HttpClient

Trait HttpClient 

Source
pub trait HttpClient:
    Send
    + Sync
    + 'static {
    // Required methods
    fn send<'life0, 'async_trait>(
        &'life0 self,
        request: HttpRequest,
    ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpClientError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn stream<'life0, 'async_trait>(
        &'life0 self,
        request: HttpRequest,
    ) -> Pin<Box<dyn Future<Output = Result<StreamingResponse, HttpClientError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
}
Expand description

An object-safe asynchronous HTTP client backend.

§Examples

use std::sync::Arc;
use millipede_core::http_client::HttpClient;

fn accepts_client(_client: Arc<dyn HttpClient>) {}

Required Methods§

Source

fn send<'life0, 'async_trait>( &'life0 self, request: HttpRequest, ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpClientError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Sends a request and buffers the complete response body.

Source

fn stream<'life0, 'async_trait>( &'life0 self, request: HttpRequest, ) -> Pin<Box<dyn Future<Output = Result<StreamingResponse, HttpClientError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Sends a request and returns a streaming response body.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§