24 lines
617 B
Rust
24 lines
617 B
Rust
|
pub mod client;
|
||
|
pub mod endpoints;
|
||
|
pub mod types;
|
||
|
|
||
|
use crate::endpoints::Endpoint;
|
||
|
use endpoints::ResponseError;
|
||
|
use serde::{de::DeserializeOwned, Serialize};
|
||
|
|
||
|
#[async_trait::async_trait(?Send)]
|
||
|
pub trait Client {
|
||
|
fn base_url(&self) -> &str;
|
||
|
|
||
|
async fn call<'a, I, O, E>(
|
||
|
&self,
|
||
|
endpoint: &E,
|
||
|
data: &I,
|
||
|
path_params: &impl AsRef<[(&'a str, &'a str)]>,
|
||
|
) -> Result<O, ResponseError>
|
||
|
where
|
||
|
I: Serialize + DeserializeOwned + Send + 'static,
|
||
|
O: Serialize + DeserializeOwned + Send + 'static,
|
||
|
E: Endpoint<Request = I, Response = O> + Send + 'static;
|
||
|
}
|