sinf 0.1.0

Library for obtaining in-depth system information at both the hardware and software levels
Documentation
mod device;
mod enumerate;
mod inner;
mod volume;

use std::ffi::OsString;

use crate::{Disk, DiskKind, DiskRefreshKind, Error as SError};

pub(crate) struct DiskInner {
    type_: DiskKind,
    name: OsString,
    volume_serial_number: Option<u32>,
    pub(crate) file_system: OsString,
    mount_point: Vec<u16>,
    s_mount_point: OsString,
    total_space: u64,
    available_space: u64,
    is_removable: bool,
    is_read_only: bool,
    device_path: Vec<u16>,
    old_written_bytes: u64,
    old_read_bytes: u64,
    written_bytes: u64,
    read_bytes: u64,
    updated: bool,
}

#[cfg(test)]
impl Default for DiskInner {
    fn default() -> Self {
        Self {
            type_: DiskKind::Unknown(0),
            name: OsString::new(),
            volume_serial_number: None,
            file_system: OsString::new(),
            mount_point: Vec::new(),
            s_mount_point: OsString::new(),
            total_space: 0,
            available_space: 0,
            is_removable: false,
            is_read_only: false,
            device_path: Vec::new(),
            old_written_bytes: 0,
            old_read_bytes: 0,
            written_bytes: 0,
            read_bytes: 0,
            updated: false,
        }
    }
}

pub(crate) struct DisksInner {
    pub(crate) disks: Vec<Disk>,
}

impl DisksInner {
    pub(crate) fn new() -> Result<Self, SError> {
        Ok(Self {
            disks: Vec::with_capacity(2),
        })
    }

    pub(crate) fn refresh_specifics(
        &mut self,
        remove_not_listed_disks: bool,
        refreshes: DiskRefreshKind,
    ) {
        unsafe {
            get_list(&mut self.disks, remove_not_listed_disks, refreshes);
        }
    }

    pub(crate) fn list(&self) -> &[Disk] {
        &self.disks
    }

    pub(crate) fn list_mut(&mut self) -> &mut [Disk] {
        &mut self.disks
    }

    pub(crate) fn into_vec(self) -> Vec<Disk> {
        self.disks
    }
}

pub(crate) use self::enumerate::get_list;