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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use std::fmt;
use heim_common::prelude::*;
use heim_common::units::Information;
use crate::sys;
#[derive(heim_derive::ImplWrap)]
pub struct IoCounters(sys::IoCounters);
impl IoCounters {
    
    pub fn interface(&self) -> &str {
        self.as_ref().interface()
    }
    
    
    pub fn bytes_sent(&self) -> Information {
        self.as_ref().bytes_sent()
    }
    
    
    pub fn bytes_recv(&self) -> Information {
        self.as_ref().bytes_recv()
    }
    
    pub fn packets_sent(&self) -> u64 {
        self.as_ref().packets_sent()
    }
    
    pub fn packets_recv(&self) -> u64 {
        self.as_ref().packets_recv()
    }
    
    
    
    pub fn errors_sent(&self) -> u64 {
        self.as_ref().errors_sent()
    }
    
    
    pub fn errors_recv(&self) -> u64 {
        self.as_ref().errors_recv()
    }
    
    pub fn drop_recv(&self) -> u64 {
        self.as_ref().drop_recv()
    }
}
impl fmt::Debug for IoCounters {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.debug_struct("IoCounters")
            .field("interface", &self.interface())
            .field("bytes_sent", &self.bytes_sent())
            .field("bytes_recv", &self.bytes_recv())
            .field("packets_sent", &self.packets_sent())
            .field("packets_recv", &self.packets_recv())
            .field("errors_sent", &self.errors_sent())
            .field("errors_recv", &self.errors_recv())
            .field("drop_recv", &self.drop_recv())
            .finish()
    }
}
pub fn io_counters() -> impl Stream<Item = Result<IoCounters>> {
    sys::io_counters().map_ok(Into::into)
}