picdl_rs/http/client.rs
1use std::{collections::HashMap, future::Future};
2
3/// Universal alias of `HashMap<String, String>`
4pub type Headers = HashMap<String, String>;
5/// Universal alias of `HashMap<String, String>`
6pub type Query = HashMap<String, String>;
7
8/// A trait that can be implemented for any HTTP
9/// client library in Rust so we can use any library
10/// easily.
11pub trait HttpClient: Send + Default {
12 /// HttpClient error type
13 type Error;
14
15 /// Function for sending GET requests
16 fn get(
17 &self,
18 url: String,
19 headers: &Headers,
20 payload: &Query,
21 ) -> impl Future<Output = Result<String, Self::Error>> + Send;
22
23 /// Function for sending POST requests
24 fn post(
25 &self,
26 url: String,
27 headers: &Headers,
28 payload: &Query,
29 ) -> impl Future<Output = Result<String, Self::Error>> + Send;
30}