pub trait DiskExt: Debug {
// Required methods
fn type_(&self) -> DiskType;
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 s = System::new();
for disk in s.disks() {
println!("{:?}: {:?}", disk.name(), disk.type_());
}
Required Methods§
sourcefn type_(&self) -> DiskType
fn type_(&self) -> DiskType
Returns the disk type.
use sysinfo::{DiskExt, System, SystemExt};
let s = System::new();
for disk in s.disks() {
println!("{:?}", disk.type_());
}
sourcefn name(&self) -> &OsStr
fn name(&self) -> &OsStr
Returns the disk name.
use sysinfo::{DiskExt, System, SystemExt};
let s = System::new();
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 s = System::new();
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 s = System::new();
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 s = System::new();
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 s = System::new();
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 s = System::new();
for disk in s.disks() {
println!("{}", disk.is_removable());
}