Struct linux_info::storage::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)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
fn print_point(point: MountPoint) -> Option<()> {
	let stat = point.stats().ok()?;

	if !stat.has_blocks() {
		return None
	}

	println!(
		"{:<15} {:>10} {:>10} {:>10} {}",
		point.mount_source()?,
		format!("{:.1}", stat.total()?),
		format!("{:.1}", stat.available()?),
		format!("{:.1}", stat.used()?),
		point.mount_point()?
	);

	Some(())
}
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)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
fn print_point(point: MountPoint) -> Option<()> {
	let stat = point.stats().ok()?;

	if !stat.has_blocks() {
		return None
	}

	println!(
		"{:<15} {:>10} {:>10} {:>10} {}",
		point.mount_source()?,
		format!("{:.1}", stat.total()?),
		format!("{:.1}", stat.available()?),
		format!("{:.1}", stat.used()?),
		point.mount_point()?
	);

	Some(())
}
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)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
fn print_point(point: MountPoint) -> Option<()> {
	let stat = point.stats().ok()?;

	if !stat.has_blocks() {
		return None
	}

	println!(
		"{:<15} {:>10} {:>10} {:>10} {}",
		point.mount_source()?,
		format!("{:.1}", stat.total()?),
		format!("{:.1}", stat.available()?),
		format!("{:.1}", stat.used()?),
		point.mount_point()?
	);

	Some(())
}
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)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
fn print_point(point: MountPoint) -> Option<()> {
	let stat = point.stats().ok()?;

	if !stat.has_blocks() {
		return None
	}

	println!(
		"{:<15} {:>10} {:>10} {:>10} {}",
		point.mount_source()?,
		format!("{:.1}", stat.total()?),
		format!("{:.1}", stat.available()?),
		format!("{:.1}", stat.used()?),
		point.mount_point()?
	);

	Some(())
}

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§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.