Skip to main content

HttpClient

Trait HttpClient 

Source
pub trait HttpClient: Send + Sync {
    // Required methods
    fn get(
        &self,
        url: Url,
    ) -> Box<dyn Future<Output = Result<Vec<u8>>> + Send + '_>;
    fn post(
        &self,
        url: Url,
        post_data: Vec<u8>,
    ) -> Box<dyn Future<Output = Result<()>> + Send + '_>;
}
Expand description

Helper trait to encapsulate different HTTP clients.

Required Methods§

Source

fn get(&self, url: Url) -> Box<dyn Future<Output = Result<Vec<u8>>> + Send + '_>

Submit a standard GET request and return the response.

Source

fn post( &self, url: Url, post_data: Vec<u8>, ) -> Box<dyn Future<Output = Result<()>> + Send + '_>

Submit a standard POST request of Content-Type equal to “application/x-www-form-urlencoded”.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl HttpClient for Client

Available on crate feature reqwest only.
Source§

fn get(&self, url: Url) -> Box<dyn Future<Output = Result<Vec<u8>>> + Send + '_>

Source§

fn post( &self, url: Url, post_data: Vec<u8>, ) -> Box<dyn Future<Output = Result<()>> + Send + '_>

Implementors§