sinf 0.1.0

Library for obtaining in-depth system information at both the hardware and software levels
Documentation
use std::ffi::OsStr;
use std::path::Path;

use crate::{DiskKind, DiskRefreshKind, DiskUsage};

/// Information about a single disk.
pub struct Disk {
    pub(crate) inner: crate::DiskInner,
}

impl Disk {
    /// Returns the disk kind.
    pub fn kind(&self) -> DiskKind {
        self.inner.kind()
    }

    /// On Unix, returns the device ID.
    pub fn id(&self) -> Option<u64> {
        self.inner.id()
    }

    /// Returns the name of the disk.
    pub fn name(&self) -> &OsStr {
        self.inner.name()
    }

    /// Returns the file system used on the disk, for example `EXT4` or `NTFS`.
    pub fn file_system(&self) -> &OsStr {
        self.inner.file_system()
    }

    /// Returns the mount point of the disk, for example `/`.
    pub fn mount_point(&self) -> &Path {
        self.inner.mount_point()
    }

    /// Returns the total size of the disk in bytes.
    pub fn total_space(&self) -> u64 {
        self.inner.total_space()
    }

    /// Returns the available size of the disk in bytes.
    pub fn available_space(&self) -> u64 {
        self.inner.available_space()
    }

    /// Returns `true` if the disk is removable.
    pub fn is_removable(&self) -> bool {
        self.inner.is_removable()
    }

    /// Returns `true` if the disk is read-only.
    pub fn is_read_only(&self) -> bool {
        self.inner.is_read_only()
    }

    /// Updates all disk information.
    pub fn refresh(&mut self) -> bool {
        self.refresh_specifics(DiskRefreshKind::everything())
    }

    /// Updates the disk information selected by the given [`DiskRefreshKind`].
    pub fn refresh_specifics(&mut self, refreshes: DiskRefreshKind) -> bool {
        self.inner.refresh_specifics(refreshes)
    }

    /// Returns the number of bytes read from and written to the disk.
    pub fn usage(&self) -> DiskUsage {
        self.inner.usage()
    }
}