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