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
use crate::from_iter;
use crate::ProcResult;
use std::io::Read;
#[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct Schedstat {
pub sum_exec_runtime: u64,
pub run_delay: u64,
pub pcount: u64,
}
impl Schedstat {
pub fn from_reader<R: Read>(mut r: R) -> ProcResult<Schedstat> {
let mut line = String::new();
r.read_to_string(&mut line)?;
let mut s = line.split_whitespace();
let schedstat = Schedstat {
sum_exec_runtime: expect!(from_iter(&mut s)),
run_delay: expect!(from_iter(&mut s)),
pcount: expect!(from_iter(&mut s)),
};
if cfg!(test) {
assert!(s.next().is_none());
}
Ok(schedstat)
}
}