1use std::time::Duration;
2
3#[derive(Debug, Clone)]
5pub struct Config {
6 pub base_url: String,
8
9 pub timeout: Duration,
11
12 pub user_agent: String,
14
15 pub retry_enabled: bool,
17
18 pub max_retries: u32,
20}
21
22impl Config {
23 pub fn mainnet() -> Self {
25 Self {
26 base_url: crate::MAINNET_BASE_URL.to_string(),
27 timeout: Duration::from_secs(30),
28 user_agent: format!("jito-api-client/{}", env!("CARGO_PKG_VERSION")),
29 retry_enabled: true,
30 max_retries: 3,
31 }
32 }
33
34 pub fn custom(base_url: impl Into<String>) -> Self {
36 Self {
37 base_url: base_url.into(),
38 timeout: Duration::from_secs(30),
39 user_agent: format!("jito-api-client/{}", env!("CARGO_PKG_VERSION")),
40 retry_enabled: true,
41 max_retries: 3,
42 }
43 }
44
45 pub fn with_timeout(mut self, timeout: Duration) -> Self {
47 self.timeout = timeout;
48 self
49 }
50
51 pub fn with_user_agent(mut self, user_agent: impl Into<String>) -> Self {
53 self.user_agent = user_agent.into();
54 self
55 }
56
57 pub fn with_retry(mut self, enabled: bool) -> Self {
59 self.retry_enabled = enabled;
60 self
61 }
62
63 pub fn with_max_retries(mut self, max_retries: u32) -> Self {
65 self.max_retries = max_retries;
66 self
67 }
68}
69
70impl Default for Config {
71 fn default() -> Self {
72 Self::mainnet()
73 }
74}