1use std::time::Duration;
2
3#[derive(Debug, Clone)]
4pub struct HyperStackConfig {
5 pub auto_reconnect: bool,
6 pub reconnect_intervals: Vec<Duration>,
7 pub max_reconnect_attempts: u32,
8 pub ping_interval: Duration,
9 pub initial_data_timeout: Duration,
10}
11
12impl Default for HyperStackConfig {
13 fn default() -> Self {
14 Self {
15 auto_reconnect: true,
16 reconnect_intervals: vec![
17 Duration::from_secs(1),
18 Duration::from_secs(2),
19 Duration::from_secs(4),
20 Duration::from_secs(8),
21 Duration::from_secs(16),
22 ],
23 max_reconnect_attempts: 5,
24 ping_interval: Duration::from_secs(15),
25 initial_data_timeout: Duration::from_secs(5),
26 }
27 }
28}
29
30#[derive(Debug, Clone)]
31pub struct ConnectionConfig {
32 pub auto_reconnect: bool,
33 pub reconnect_intervals: Vec<Duration>,
34 pub max_reconnect_attempts: u32,
35 pub ping_interval: Duration,
36}
37
38impl From<HyperStackConfig> for ConnectionConfig {
39 fn from(config: HyperStackConfig) -> Self {
40 Self {
41 auto_reconnect: config.auto_reconnect,
42 reconnect_intervals: config.reconnect_intervals,
43 max_reconnect_attempts: config.max_reconnect_attempts,
44 ping_interval: config.ping_interval,
45 }
46 }
47}
48
49impl Default for ConnectionConfig {
50 fn default() -> Self {
51 HyperStackConfig::default().into()
52 }
53}