1use futures::Stream;
2use serde::{de::DeserializeOwned, Serialize};
3use std::{fmt::Debug, pin::Pin};
4
5use crate::error::Error;
6
7pub mod simple;
8pub mod stream;
9pub use simple::SimpleHttpClient;
10
11#[async_trait::async_trait]
12pub trait HttpClient: Debug + Clone + Send + Sync {
13 async fn post<I: Serialize + Send, O: DeserializeOwned>(
14 &self,
15 path: &str,
16 request: I,
17 ) -> Result<O, Error>;
18 async fn post_stream<I: Serialize + Send, O: DeserializeOwned + Send + 'static>(
19 &self,
20 path: &str,
21 request: I,
22 ) -> Result<Pin<Box<dyn Stream<Item = Result<O, Error>> + Send>>, Error>;
23}