pub struct Disk { /* private fields */ }Expand description
Struct containing a disk information.
use sysinfo::Disks;
if let Ok(disks) = Disks::new_with_refreshed_list() {
for disk in &disks {
println!("{:?}: {:?}", disk.name(), disk.kind());
}
}Implementations§
Source§impl Disk
impl Disk
Sourcepub fn kind(&self) -> DiskKind
pub fn kind(&self) -> DiskKind
Returns the kind of disk.
use sysinfo::Disks;
if let Ok(disks) = Disks::new_with_refreshed_list() {
for disk in &disks {
println!("[{:?}] {:?}", disk.name(), disk.kind());
}
}Sourcepub fn id(&self) -> Option<u64>
pub fn id(&self) -> Option<u64>
On Unix, returns the Unix device ID.
On Windows, returns the Volume Serial Number.
Returns None if the device ID or the Volume Serial Number cannot be retrieved.
use sysinfo::Disks;
if let Ok(disks) = Disks::new_with_refreshed_list() {
for disk in &disks {
println!("[{:?}] {:?}", disk.name(), disk.id());
}
}Sourcepub fn name(&self) -> &OsStr
pub fn name(&self) -> &OsStr
Returns the disk name.
use sysinfo::Disks;
if let Ok(disks) = Disks::new_with_refreshed_list() {
for disk in &disks {
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;
if let Ok(disks) = Disks::new_with_refreshed_list() {
for disk in &disks {
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;
if let Ok(disks) = Disks::new_with_refreshed_list() {
for disk in &disks {
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;
if let Ok(disks) = Disks::new_with_refreshed_list() {
for disk in &disks {
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;
if let Ok(disks) = Disks::new_with_refreshed_list() {
for disk in &disks {
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;
if let Ok(disks) = Disks::new_with_refreshed_list() {
for disk in &disks {
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;
if let Ok(disks) = Disks::new_with_refreshed_list() {
for disk in &disks {
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;
if let Ok(mut disks) = Disks::new_with_refreshed_list() {
for disk in &mut disks {
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};
if let Ok(mut disks) = Disks::new_with_refreshed_list() {
for disk in &mut disks {
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 UnsafeUnpin 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