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
use std::io::Read;
use byteorder::{ByteOrder, ReadBytesExt};
#[derive(Debug, Clone, Copy)]
pub struct NrCpus {
pub nr_cpus_available: u32,
pub nr_cpus_online: u32,
}
impl NrCpus {
pub const STRUCT_SIZE: usize = 4 + 4;
pub fn parse<R: Read, T: ByteOrder>(mut reader: R) -> Result<Self, std::io::Error> {
let nr_cpus_available = reader.read_u32::<T>()?;
let nr_cpus_online = reader.read_u32::<T>()?;
Ok(Self {
nr_cpus_available,
nr_cpus_online,
})
}
}
#[derive(Debug, Clone, Copy)]
pub struct SampleTimeRange {
pub first_sample_time: u64,
pub last_sample_time: u64,
}
impl SampleTimeRange {
pub const STRUCT_SIZE: usize = 8 + 8;
pub fn parse<R: Read, T: ByteOrder>(mut reader: R) -> Result<Self, std::io::Error> {
let first_sample_time = reader.read_u64::<T>()?;
let last_sample_time = reader.read_u64::<T>()?;
Ok(Self {
first_sample_time,
last_sample_time,
})
}
}