#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Deserialize, Serialize)]
#[repr(transparent)]
pub struct NumberOfInodes(pub usize);
impl From<usize> for NumberOfInodes
{
#[inline(always)]
fn from(value: usize) -> Self
{
Self(value)
}
}
impl Into<usize> for NumberOfInodes
{
#[inline(always)]
fn into(self) -> usize
{
self.0
}
}
impl NumberOfInodes
{
#[inline(always)]
pub fn allocated_and_free(proc_path: &ProcPath) -> io::Result<(Self, Self)>
{
let bytes = proc_path.sys_fs_file_path("inode-nr").read_raw_without_line_feed()?;
let mut fields = bytes.split_bytes_n(2, b'\t');
#[inline(always)]
fn next<'a>(fields: &mut impl Iterator<Item=&'a [u8]>) -> NumberOfInodes
{
NumberOfInodes(usize::parse_decimal_number(fields.next().unwrap()).unwrap())
}
Ok((next(&mut fields), next(&mut fields)))
}
}