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§
sourcefn kind(&self) -> DiskKind
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());
}
sourcefn name(&self) -> &OsStr
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());
}
sourcefn file_system(&self) -> &[u8] ⓘ
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());
}
sourcefn mount_point(&self) -> &Path
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());
}
sourcefn total_space(&self) -> u64
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());
}
sourcefn available_space(&self) -> u64
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());
}
sourcefn is_removable(&self) -> bool
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());
}