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
use std::fmt;
use heim_common::prelude::*;
use crate::sys;
pub struct CpuStats(sys::CpuStats);
wrap!(CpuStats, sys::CpuStats);
impl CpuStats {
pub fn ctx_switches(&self) -> u64 {
self.as_ref().ctx_switches()
}
pub fn interrupts(&self) -> u64 {
self.as_ref().interrupts()
}
}
impl fmt::Debug for CpuStats {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("CpuStats")
.field("ctx_switches", &self.ctx_switches())
.field("interrupts", &self.interrupts())
.finish()
}
}
pub fn stats() -> impl Future<Output = Result<CpuStats>> {
sys::stats().map_ok(Into::into)
}