#[derive(Default, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct MemoryEventStatistics
{
pub low: usize,
pub high: usize,
pub maximum: usize,
pub oom: usize,
pub oom_kill: usize,
}
impl MemoryEventStatistics
{
#[inline(always)]
pub(crate) fn from_file(file_path: &Path) -> Result<Self, StatisticsParseError>
{
let mut low = None;
let mut high = None;
let mut max = None;
let mut oom = None;
let mut oom_kill = None;
parse_key_value_statistics(file_path, &mut |name, value|
{
match name
{
b"low" =>
{
low = Some(value);
}
b"high" =>
{
high = Some(value);
}
b"max" =>
{
max = Some(value);
}
b"oom" =>
{
oom = Some(value);
}
b"oom_kill" =>
{
oom_kill = Some(value);
}
_ => (),
};
Ok(())
})?;
Ok
(
Self
{
low: unwrap_statistic(low, b"low")?,
high: unwrap_statistic(high, b"high")?,
maximum: unwrap_statistic(max, b"max")?,
oom: unwrap_statistic(oom, b"oom")?,
oom_kill: unwrap_statistic(oom_kill, b"oom_kill")?,
}
)
}
}