1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::error::Error;
use async_trait::async_trait;
use bytes::Bytes;
use http::{request::Builder as RequestBuilder, Response};
use url::Url;
use super::error::ApiError;
pub trait RestClient {
type Error: Error + Send + Sync + 'static;
fn rest_endpoint(&self, endpoint: &str) -> Result<Url, ApiError<Self::Error>>;
fn has_api_key(&self) -> bool;
}
pub trait Client: RestClient {
fn rest(
&self,
request: RequestBuilder,
body: Vec<u8>,
) -> Result<Response<Bytes>, ApiError<Self::Error>>;
}
#[async_trait]
pub trait AsyncClient: RestClient {
async fn rest_async(
&self,
request: RequestBuilder,
body: Vec<u8>,
) -> Result<Response<Bytes>, ApiError<Self::Error>>;
}