starlane_space/space/
settings.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use crate::space::wave::WaitTime;

// measured in seconds
#[derive(Clone)]
pub struct Timeouts {
    pub high: u64,
    pub med: u64,
    pub low: u64,
}

impl Timeouts {
    pub fn from<W: Into<WaitTime>>(&self, wait: W) -> u64 {
        match wait.into() {
            WaitTime::High => self.high,
            WaitTime::Med => self.med,
            WaitTime::Low => self.low,
        }
    }

    pub fn from_wait(&self, wait: &WaitTime ) -> u64 {
        match wait {
            WaitTime::High => self.high,
            WaitTime::Med => self.med,
            WaitTime::Low => self.low,
        }
    }
}


impl Default for Timeouts {
    fn default() -> Self {
        Self {
            high: 5 * 60, // 5 minutes
            med: 1 * 60,  // 1 minute
            low: 15,      // 15 seconds
        }
    }
}