Trait sysinfo::DiskExt

source ·
pub trait DiskExt: Debug {
    // Required methods
    fn kind(&self) -> DiskKind;
    fn name(&self) -> &OsStr;
    fn file_system(&self) -> &[u8] ;
    fn mount_point(&self) -> &Path;
    fn total_space(&self) -> u64;
    fn available_space(&self) -> u64;
    fn is_removable(&self) -> bool;
    fn refresh(&mut self) -> bool;
}
Expand description

Contains all the methods of the Disk struct.

use sysinfo::{DiskExt, System, SystemExt};

let mut s = System::new();
s.refresh_disks_list();
for disk in s.disks() {
    println!("{:?}: {:?}", disk.name(), disk.kind());
}

Required Methods§

source

fn kind(&self) -> DiskKind

Returns the kind of disk.

use sysinfo::{DiskExt, System, SystemExt};

let mut s = System::new();
s.refresh_disks_list();
for disk in s.disks() {
    println!("{:?}", disk.kind());
}
source

fn name(&self) -> &OsStr

Returns the disk name.

use sysinfo::{DiskExt, System, SystemExt};

let mut s = System::new();
s.refresh_disks_list();
for disk in s.disks() {
    println!("{:?}", disk.name());
}
source

fn file_system(&self) -> &[u8]

Returns the file system used on this disk (so for example: EXT4, NTFS, etc…).

use sysinfo::{DiskExt, System, SystemExt};

let mut s = System::new();
s.refresh_disks_list();
for disk in s.disks() {
    println!("{:?}", disk.file_system());
}
source

fn mount_point(&self) -> &Path

Returns the mount point of the disk (/ for example).

use sysinfo::{DiskExt, System, SystemExt};

let mut s = System::new();
s.refresh_disks_list();
for disk in s.disks() {
    println!("{:?}", disk.mount_point());
}
source

fn total_space(&self) -> u64

Returns the total disk size, in bytes.

use sysinfo::{DiskExt, System, SystemExt};

let mut s = System::new();
s.refresh_disks_list();
for disk in s.disks() {
    println!("{}", disk.total_space());
}
source

fn available_space(&self) -> u64

Returns the available disk size, in bytes.

use sysinfo::{DiskExt, System, SystemExt};

let mut s = System::new();
s.refresh_disks_list();
for disk in s.disks() {
    println!("{}", disk.available_space());
}
source

fn is_removable(&self) -> bool

Returns true if the disk is removable.

use sysinfo::{DiskExt, System, SystemExt};

let mut s = System::new();
s.refresh_disks_list();
for disk in s.disks() {
    println!("{}", disk.is_removable());
}
source

fn refresh(&mut self) -> bool

Updates the disk’ information.

use sysinfo::{DiskExt, System, SystemExt};

let mut s = System::new();
s.refresh_disks_list();
for disk in s.disks_mut() {
    disk.refresh();
}

Implementors§