#[derive(Copy, Clone, Debug)]
pub enum RecursiveSize {
None,
Unknown,
#[cfg_attr(target_family = "windows", allow(dead_code))]
Some(u64, u64),
}
impl RecursiveSize {
#[inline]
#[must_use]
pub const fn is_none(&self) -> bool {
matches!(*self, Self::None)
}
#[inline]
#[must_use]
pub const fn unwrap_bytes_or(self, default: u64) -> u64 {
match self {
Self::Some(bytes, _blocks) => bytes,
_ => default,
}
}
#[inline]
#[cfg_attr(target_family = "windows", allow(dead_code))]
pub fn map_or<U, F>(self, default: U, f: F) -> U
where
F: FnOnce(u64, u64) -> U,
{
match self {
RecursiveSize::Some(bytes, blocks) => f(bytes, blocks),
_ => default,
}
}
}