api_builder/client/
mod.rs1use core::future::Future;
2
3use bytes::Bytes;
4use http::{Request, Response};
5use url::Url;
6
7use crate::APIError;
8
9#[cfg(feature = "reqwest")]
10import!(reqwest);
11#[cfg(target_family = "wasm")]
12#[cfg(not(feature = "reqwest"))]
13import!(wasm);
14
15pub trait RestClient {
17 type Error;
19
20 fn rest_endpoint(&self, path: &str) -> Result<Url, APIError<Self::Error>>;
24}
25
26pub trait Client: RestClient {
28 fn rest(&self, request: Request<Vec<u8>>) -> Result<Response<Bytes>, APIError<Self::Error>>;
30}
31
32pub trait AsyncClient: RestClient {
34 #[cfg(not(target_arch = "wasm32"))]
35 fn rest_async(
37 &self,
38 request: Request<Vec<u8>>,
39 ) -> impl Future<Output = Result<Response<Bytes>, APIError<Self::Error>>> + Send;
40
41 #[cfg(target_arch = "wasm32")]
42 fn rest_async(
44 &self,
45 request: Request<Vec<u8>>,
46 ) -> impl Future<Output = Result<Response<Bytes>, APIError<Self::Error>>>;
47}