pub struct Disk { /* private fields */ }
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());
}
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());
}
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§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more