Struct FsStat

Source
pub struct FsStat { /* private fields */ }
Expand description

Filesystem statistics

Implementations§

Source§

impl FsStat

Source

pub fn read(path: impl AsRef<Path>) -> Result<Self>

Reads filesystems staticstics for a given file descriptor.

Source

pub fn has_blocks(&self) -> bool

Returns true if the total blocks is bigger than zero.

Examples found in repository?
examples/df_h.rs (line 20)
17fn print_point(point: MountPoint) -> Option<()> {
18	let stat = point.stats().ok()?;
19
20	if !stat.has_blocks() {
21		return None
22	}
23
24	println!(
25		"{:<15} {:>10} {:>10} {:>10} {}",
26		point.mount_source()?,
27		format!("{:.1}", stat.total()?),
28		format!("{:.1}", stat.available()?),
29		format!("{:.1}", stat.used()?),
30		point.mount_point()?
31	);
32
33	Some(())
34}
Source

pub fn block_size(&self) -> Option<usize>

The block size in bytes used for this filesystem.

Source

pub fn total_blocks(&self) -> Option<usize>

The total block count.

Source

pub fn free_blocks(&self) -> Option<usize>

The blocks that are still free may not all be accessible to unprivileged users.

Source

pub fn available_blocks(&self) -> Option<usize>

The blocks that are free and accessible to unprivileged users.

Source

pub fn used_blocks(&self) -> Option<usize>

The blocks that are already used.

Source

pub fn total(&self) -> Option<DataSize>

The size of the filesystem.

Examples found in repository?
examples/df_h.rs (line 27)
17fn print_point(point: MountPoint) -> Option<()> {
18	let stat = point.stats().ok()?;
19
20	if !stat.has_blocks() {
21		return None
22	}
23
24	println!(
25		"{:<15} {:>10} {:>10} {:>10} {}",
26		point.mount_source()?,
27		format!("{:.1}", stat.total()?),
28		format!("{:.1}", stat.available()?),
29		format!("{:.1}", stat.used()?),
30		point.mount_point()?
31	);
32
33	Some(())
34}
Source

pub fn free(&self) -> Option<DataSize>

The size of the free space.

Source

pub fn available(&self) -> Option<DataSize>

The size of the available space to unprivileged users.

Examples found in repository?
examples/df_h.rs (line 28)
17fn print_point(point: MountPoint) -> Option<()> {
18	let stat = point.stats().ok()?;
19
20	if !stat.has_blocks() {
21		return None
22	}
23
24	println!(
25		"{:<15} {:>10} {:>10} {:>10} {}",
26		point.mount_source()?,
27		format!("{:.1}", stat.total()?),
28		format!("{:.1}", stat.available()?),
29		format!("{:.1}", stat.used()?),
30		point.mount_point()?
31	);
32
33	Some(())
34}
Source

pub fn used(&self) -> Option<DataSize>

The size of the space that is currently used.

Examples found in repository?
examples/df_h.rs (line 29)
17fn print_point(point: MountPoint) -> Option<()> {
18	let stat = point.stats().ok()?;
19
20	if !stat.has_blocks() {
21		return None
22	}
23
24	println!(
25		"{:<15} {:>10} {:>10} {:>10} {}",
26		point.mount_source()?,
27		format!("{:.1}", stat.total()?),
28		format!("{:.1}", stat.available()?),
29		format!("{:.1}", stat.used()?),
30		point.mount_point()?
31	);
32
33	Some(())
34}

Trait Implementations§

Source§

impl Clone for FsStat

Source§

fn clone(&self) -> FsStat

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

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for FsStat

§

impl RefUnwindSafe for FsStat

§

impl Send for FsStat

§

impl Sync for FsStat

§

impl Unpin for FsStat

§

impl UnwindSafe for FsStat

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.