1use std::time::Duration;
2use reqwest::ClientBuilder;
3use std::sync::Arc;
4
5#[derive(Clone)]
6pub struct Config {
7 pub username: String,
8 pub password: String,
9 pub base_url: Option<String>,
10 pub timeout: Option<Duration>,
11 pub http_client_hook: Option<Arc<dyn Fn(ClientBuilder) -> ClientBuilder + Send + Sync>>,
12
13}
14
15impl Config {
16 pub fn new<S: Into<String>>(username: S, password: S) -> Self {
17 Self {
18 username: username.into(),
19 password: password.into(),
20 base_url: None,
21 timeout: None,
22 http_client_hook: None,
23 }
24 }
25
26 pub fn with_base_url<S: Into<String>>(mut self, base_url: S) -> Self {
27 self.base_url = Some(base_url.into());
28 self
29 }
30
31 pub fn with_timeout(mut self, timeout: Duration) -> Self {
32 self.timeout = Some(timeout);
33 self
34 }
35
36 pub fn with_http_client_hook(mut self, hook: Arc<dyn Fn(ClientBuilder) -> ClientBuilder + Send + Sync>) -> Self {
37 self.http_client_hook = Some(hook);
38 self
39 }
40}