serenade_http_client/
client.rs1use crate::{ClientRequest, ClientResponse, HttpClientError};
4
5pub trait HttpClient: Send + Sync {
7 fn send(
13 &self,
14 request: ClientRequest,
15 ) -> impl std::future::Future<Output = Result<ClientResponse, HttpClientError>> + Send;
16
17 fn get(
23 &self,
24 url: impl Into<String> + Send,
25 ) -> impl std::future::Future<Output = Result<ClientResponse, HttpClientError>> + Send {
26 async move { self.send(ClientRequest::get(url)).await }
27 }
28
29 fn post(
35 &self,
36 url: impl Into<String> + Send,
37 body: impl Into<Vec<u8>> + Send,
38 ) -> impl std::future::Future<Output = Result<ClientResponse, HttpClientError>> + Send {
39 async move { self.send(ClientRequest::post(url).body(body)).await }
40 }
41}