pub struct InodeUsage { /* private fields */ }Expand description
Inode occupancy of one filesystem.
A separate type from the byte figures because it answers a different question,
and a classic operational surprise: a filesystem can refuse a create with
ENOSPC while df shows plenty of free space, because what ran out was the
inode table. Nothing else in this model can express that.
The fields are private so that the two invariants a reader relies on hold by
construction: total is never zero — a filesystem with no inode table reports
MetricState::Unsupported instead, never 0 of 0 (§4) — and free never
exceeds total, so InodeUsage::used cannot underflow into a huge number.
Implementations§
Source§impl InodeUsage
impl InodeUsage
Sourcepub const fn from_counts(total: u64, free: u64) -> MetricState<Self>
pub const fn from_counts(total: u64, free: u64) -> MetricState<Self>
The state a statfs/statvfs (f_files, f_ffree) pair describes.
A zero total is what a filesystem with no fixed inode table reports, and
many do: it is MetricState::Unsupported, because “this filesystem has
no inode limit” and “0 inodes exist” are opposite claims and only the first
is true (§4, §26).
Sourcepub const fn used(self) -> u64
pub const fn used(self) -> u64
Inodes in use: one per file, directory, symlink, and device node.
Sourcepub fn usage(self) -> Percent
pub fn usage(self) -> Percent
Share of the inode table in use.
Infallible, unlike the byte-capacity percentage, because Self::from_counts
has already rejected the zero-total case. The fallback exists only because
Percent::ratio cannot see that invariant, and it is the pessimistic
reading on purpose: a table whose size somehow could not be divided by is
reported as full, never as empty, since “empty” is the reassuring answer and
an uninterpretable count is not a reassuring situation.
Trait Implementations§
Source§impl Clone for InodeUsage
impl Clone for InodeUsage
Source§fn clone(&self) -> InodeUsage
fn clone(&self) -> InodeUsage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more