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
use std::fmt;
use heim_common::units::{information, Information};
#[derive(Default)]
pub struct IoCounters {
pub(crate) rchar: u64,
pub(crate) wchar: u64,
pub(crate) syscr: u64,
pub(crate) syscw: u64,
pub(crate) read_bytes: u64,
pub(crate) write_bytes: u64,
pub(crate) cancelled_write_bytes: u64,
}
impl IoCounters {
pub fn chars_read(&self) -> Information {
Information::new::<information::byte>(self.rchar)
}
pub fn chars_written(&self) -> Information {
Information::new::<information::byte>(self.wchar)
}
pub fn read_syscalls(&self) -> u64 {
self.syscr
}
pub fn write_syscalls(&self) -> u64 {
self.syscw
}
pub fn bytes_read(&self) -> Information {
Information::new::<information::byte>(self.read_bytes)
}
pub fn bytes_written(&self) -> Information {
Information::new::<information::byte>(self.write_bytes)
}
pub fn cancelled_write_bytes(&self) -> Information {
Information::new::<information::byte>(self.cancelled_write_bytes)
}
}
impl fmt::Debug for IoCounters {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("IoCounters")
.field("chars_read", &self.chars_read())
.field("chars_written", &self.chars_written())
.field("read_syscalls", &self.read_syscalls())
.field("write_syscalls", &self.write_syscalls())
.field("bytes_read", &self.bytes_read())
.field("bytes_written", &self.bytes_written())
.field("cancelled_write_bytes", &self.cancelled_write_bytes())
.finish()
}
}