pub struct Disk {
pub(crate) inner: DiskInner,
}
Expand description
Struct containing a disk information.
use sysinfo::Disks;
let disks = Disks::new_with_refreshed_list();
for disk in disks.list() {
println!("{:?}: {:?}", disk.name(), disk.kind());
}
Fields§
§inner: DiskInner
Implementations§
Source§impl Disk
impl Disk
Sourcepub fn kind(&self) -> DiskKind
pub fn kind(&self) -> DiskKind
Returns the kind of disk.
use sysinfo::Disks;
let disks = Disks::new_with_refreshed_list();
for disk in disks.list() {
println!("[{:?}] {:?}", disk.name(), disk.kind());
}
Sourcepub fn name(&self) -> &OsStr
pub fn name(&self) -> &OsStr
Returns the disk name.
use sysinfo::Disks;
let disks = Disks::new_with_refreshed_list();
for disk in disks.list() {
println!("{:?}", disk.name());
}
Sourcepub fn file_system(&self) -> &OsStr
pub fn file_system(&self) -> &OsStr
Returns the file system used on this disk (so for example: EXT4
, NTFS
, etc…).
use sysinfo::Disks;
let disks = Disks::new_with_refreshed_list();
for disk in disks.list() {
println!("[{:?}] {:?}", disk.name(), disk.file_system());
}
Sourcepub fn mount_point(&self) -> &Path
pub fn mount_point(&self) -> &Path
Returns the mount point of the disk (/
for example).
use sysinfo::Disks;
let disks = Disks::new_with_refreshed_list();
for disk in disks.list() {
println!("[{:?}] {:?}", disk.name(), disk.mount_point());
}
Sourcepub fn total_space(&self) -> u64
pub fn total_space(&self) -> u64
Returns the total disk size, in bytes.
use sysinfo::Disks;
let disks = Disks::new_with_refreshed_list();
for disk in disks.list() {
println!("[{:?}] {}B", disk.name(), disk.total_space());
}
Sourcepub fn available_space(&self) -> u64
pub fn available_space(&self) -> u64
Returns the available disk size, in bytes.
use sysinfo::Disks;
let disks = Disks::new_with_refreshed_list();
for disk in disks.list() {
println!("[{:?}] {}B", disk.name(), disk.available_space());
}
Sourcepub fn is_removable(&self) -> bool
pub fn is_removable(&self) -> bool
Returns true
if the disk is removable.
use sysinfo::Disks;
let disks = Disks::new_with_refreshed_list();
for disk in disks.list() {
println!("[{:?}] {}", disk.name(), disk.is_removable());
}
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
Returns true
if the disk is read-only.
use sysinfo::Disks;
let disks = Disks::new_with_refreshed_list();
for disk in disks.list() {
println!("[{:?}] is read-only: {}", disk.name(), disk.is_read_only());
}
Sourcepub fn refresh(&mut self) -> bool
pub fn refresh(&mut self) -> bool
Updates the disk’ information with everything loaded.
Equivalent to Disk::refresh_specifics(DiskRefreshKind::everything())
.
use sysinfo::Disks;
let mut disks = Disks::new_with_refreshed_list();
for disk in disks.list_mut() {
disk.refresh();
}
Sourcepub fn refresh_specifics(&mut self, refreshes: DiskRefreshKind) -> bool
pub fn refresh_specifics(&mut self, refreshes: DiskRefreshKind) -> bool
Updates the disk’s information corresponding to the given DiskRefreshKind
.
use sysinfo::{Disks, DiskRefreshKind};
let mut disks = Disks::new_with_refreshed_list();
for disk in disks.list_mut() {
disk.refresh_specifics(DiskRefreshKind::nothing());
}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Disk
impl RefUnwindSafe for Disk
impl Send for Disk
impl Sync for Disk
impl Unpin for Disk
impl UnwindSafe for Disk
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more