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