StatFs

Struct StatFs 

Source
pub struct StatFs {
    pub total_bytes: u64,
    pub used_bytes: u64,
    pub available_bytes: u64,
    pub total_inodes: u64,
    pub used_inodes: u64,
    pub available_inodes: u64,
    pub block_size: u64,
    pub max_name_len: u64,
}
Expand description

Filesystem-level statistics.

Returned by FsStats::statfs. Contains information about the filesystem’s capacity, usage, and limits — similar to the POSIX statvfs system call.

§Fields

FieldTypeDescription
total_bytesu64Total capacity (0 = unlimited)
used_bytesu64Currently used space
available_bytesu64Space available for new data
total_inodesu64Maximum files/directories (0 = unlimited)
used_inodesu64Currently allocated inodes
available_inodesu64Inodes available for new entries
block_sizeu64Filesystem block size in bytes
max_name_lenu64Maximum filename length

§Example

use anyfs_backend::StatFs;

let stats = StatFs {
    total_bytes: 1_000_000_000,        // 1 GB
    used_bytes: 250_000_000,           // 250 MB used
    available_bytes: 750_000_000,      // 750 MB free
    total_inodes: 100_000,
    used_inodes: 1_234,
    available_inodes: 98_766,
    block_size: 4096,
    max_name_len: 255,
};

let usage_percent = (stats.used_bytes as f64 / stats.total_bytes as f64) * 100.0;
println!("Disk usage: {:.1}%", usage_percent);  // "Disk usage: 25.0%"

§Unlimited Filesystems

For backends without fixed limits (e.g., cloud storage), set capacity fields to 0:

use anyfs_backend::StatFs;

let unlimited = StatFs {
    total_bytes: 0,      // No limit
    total_inodes: 0,     // No limit
    ..Default::default()
};

Fields§

§total_bytes: u64

Total size in bytes (0 = unlimited).

§used_bytes: u64

Currently used bytes.

§available_bytes: u64

Available bytes for use.

§total_inodes: u64

Total number of inodes (0 = unlimited).

§used_inodes: u64

Number of used inodes.

§available_inodes: u64

Number of available inodes.

§block_size: u64

Block size in bytes.

§max_name_len: u64

Maximum filename length.

Trait Implementations§

Source§

impl Clone for StatFs

Source§

fn clone(&self) -> StatFs

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StatFs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StatFs

Source§

fn default() -> StatFs

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for StatFs

§

impl RefUnwindSafe for StatFs

§

impl Send for StatFs

§

impl Sync for StatFs

§

impl Unpin for StatFs

§

impl UnwindSafe for StatFs

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.