• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ensc / r-tftpd / 6956076908

22 Nov 2023 10:34AM UTC coverage: 71.499% (+1.1%) from 70.425%
6956076908

Pull #11

github

web-flow
Merge 53ecd94b6 into 88fc02a77
Pull Request #11: Next

187 of 261 new or added lines in 8 files covered. (71.65%)

9 existing lines in 4 files now uncovered.

1884 of 2635 relevant lines covered (71.5%)

383.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.0
/mod-proxy/src/http/time.rs
1
use std::time::{SystemTime, Duration, Instant};
2

UNCOV
3
#[derive(Copy, Clone, Debug)]
×
4
pub struct Time {
5
    pub local:        SystemTime,
6
    pub mono:        std::time::Instant,
×
7
}
8

9
impl Time {
10
    pub fn now() -> Self {
200✔
11
        Self {
200✔
12
            local:        SystemTime::now(),
200✔
13
            mono:        std::time::Instant::now(),
200✔
14
        }
15
    }
200✔
16
}
17

18
impl PartialEq for Time {
NEW
19
    fn eq(&self, other: &Self) -> bool {
×
NEW
20
        self.mono == other.mono
×
UNCOV
21
    }
×
22
}
23

24
impl PartialOrd for Time {
NEW
25
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
×
NEW
26
        self.mono.partial_cmp(&other.mono)
×
NEW
27
    }
×
28
}
29

NEW
30
#[derive(Debug)]
×
31
pub struct TimeDelta(i64);
1✔
32

33
impl TimeDelta {
34
    pub fn from_systemtime(a: SystemTime, b: SystemTime) -> Option<Self> {
1✔
35
        let (delta, sign) = match a < b {
2✔
36
            true        => (b.duration_since(a),  1),
1✔
NEW
37
            false        => (a.duration_since(b), -1),
×
38
        };
39

40
        delta.ok()
3✔
41
            .and_then(|t| i64::try_from(t.as_nanos()).ok())
1✔
42
            .or_else(|| {
1✔
NEW
43
                warn!("failed to calculate delta of {a:?} and {b:?}");
×
NEW
44
                None
×
NEW
45
            })
×
46
            .map(|t| match sign {
2✔
47
                s if s < 0        => -t,
1✔
48
                _                =>  t,
1✔
49
            })
1✔
50
            .map(Self)
51
    }
1✔
52
}
53

54
impl std::ops::Add<TimeDelta> for SystemTime {
55
    type Output = Option<SystemTime>;
56

NEW
57
    fn add(self, rhs: TimeDelta) -> Self::Output {
×
NEW
58
        match rhs.0 < 0 {
×
NEW
59
            true        => self.checked_sub(Duration::from_nanos(-rhs.0 as u64)),
×
NEW
60
            false        => self.checked_add(Duration::from_nanos( rhs.0 as u64)),
×
61
        }
62
    }
×
63
}
64

65
impl std::ops::Sub<TimeDelta> for SystemTime {
66
    type Output = Option<SystemTime>;
67

NEW
68
    fn sub(self, rhs: TimeDelta) -> Self::Output {
×
NEW
69
        match rhs.0 < 0 {
×
NEW
70
            true        => self.checked_add(Duration::from_nanos(-rhs.0 as u64)),
×
NEW
71
            false        => self.checked_sub(Duration::from_nanos( rhs.0 as u64)),
×
72
        }
UNCOV
73
    }
×
74
}
75

76
impl std::ops::Add<TimeDelta> for Instant {
77
    type Output = Option<Instant>;
78

79
    fn add(self, rhs: TimeDelta) -> Self::Output {
1✔
80
        match rhs.0 < 0 {
1✔
NEW
81
            true        => self.checked_sub(Duration::from_nanos(-rhs.0 as u64)),
×
82
            false        => self.checked_add(Duration::from_nanos( rhs.0 as u64)),
1✔
83
        }
84
    }
1✔
85
}
86

87
impl std::ops::Sub<TimeDelta> for Instant {
88
    type Output = Option<Instant>;
89

NEW
90
    fn sub(self, rhs: TimeDelta) -> Self::Output {
×
NEW
91
        match rhs.0 < 0 {
×
NEW
92
            true        => self.checked_add(Duration::from_nanos(-rhs.0 as u64)),
×
NEW
93
            false        => self.checked_sub(Duration::from_nanos( rhs.0 as u64)),
×
94
        }
UNCOV
95
    }
×
96
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc