qweather_http_client/
lib.rs1use serde::de::DeserializeOwned;
2use std::{collections::HashMap, future::Future};
3
4#[cfg(feature = "reqwest-http-client")]
5mod reqwest;
6#[cfg(feature = "reqwest-http-client")]
7pub use reqwest::{ReqwestHttpAsyncClient, ReqwestHttpAsyncClientConfiguration};
8
9pub static GEO_API_URL: &str = "https://geoapi.qweather.com";
10pub static WEATHER_API_URL: &str = "https://api.qweather.com";
11pub static WEATHER_DEV_API_URL: &str = "https://devapi.qweather.com";
12
13#[derive(Debug, Clone, Default)]
14pub enum Api {
15 Geo,
16 #[default]
17 Weather,
18}
19
20#[derive(Debug, Clone, Default)]
21pub struct HttpRequest {
22 pub api: Api,
23 pub path: String,
24 pub query: HashMap<String, String>,
25}
26
27pub trait AsyncHttpClient {
28 type Error;
29 fn get<T: DeserializeOwned>(
30 &self,
31 req: HttpRequest,
32 ) -> impl Future<Output = Result<T, Self::Error>> + Send;
33}