Struct Disk

Source
pub struct Disk {
    pub disk: PathBuf,
    /* private fields */
}
Expand description

Our ata smart disk

Fields§

§disk: PathBuf

The path in the filesystem to the hard drive

Implementations§

Source§

impl Disk

Source

pub fn new(disk_path: &Path) -> Result<Disk, Errno>

This will initialize a new Disk by asking libatasmart to open it. Note that this requires root permissions usually to succeed.

Source

pub fn refresh_smart_data(&mut self) -> Result<(), Errno>

Refreshes cached SMART attribute values.

SMART attribute values are read once in Disk::new and cached. Methods such as get_temperature use these cached values and do not access the disk. Call this method to refresh the cached values.

Note: calling this method might cause the disk to wake up from sleep. Consider checking if the disk is asleep using check_sleep_mode before calling this method to avoid this.

Source

pub fn get_disk_size(&mut self) -> Result<u64, Errno>

Returns a u64 representing the size of the disk in bytes.

Source

pub fn check_sleep_mode(&mut self) -> Result<bool, Errno>

Returns a bool of true if sleep mode is supported, false otherwise.

Source

pub fn get_power_on(&mut self) -> Result<u64, Errno>

Returns a u64 representing the power on time in milliseconds

Source

pub fn get_power_cycle_count(&mut self) -> Result<u64, Errno>

Returns a u64 representing the number of power on cycles

Source

pub fn get_bad_sectors(&mut self) -> Result<u64, Errno>

Returns a u64 representing the number of bad sections on the disk

Source

pub fn get_temperature(&mut self) -> Result<u64, Errno>

Returns a u64 representing the mkelvin of the disk

Source

pub fn get_smart_status(&mut self) -> Result<bool, Errno>

Returns true if the disk passed smart, false otherwise.

Source

pub fn dump(&mut self) -> Result<(), Errno>

This will dump all available information to stdout about the drive

Source

pub fn identify_is_available(&mut self) -> Result<bool, Errno>

Source

pub fn smart_is_available(&mut self) -> Result<bool, Errno>

Query the device and return whether or not smart is supported on it

Source

pub unsafe fn parse_attributes( &mut self, parser_callback: extern "C" fn(*mut SkDisk, *const SkSmartAttributeParsedData, *mut c_void), userdata: *mut c_void, ) -> Result<(), Errno>

This is a lower level function that is used to build new smart functions

§Safety

This function is unsafe because it dereferences raw pointers and calls an external C function. The caller must ensure that parser_callback and userdata are valid and that self.skdisk is properly initialized.

Source

pub fn smart_test_available( &mut self, test_attributes: &mut SkSmartParsedData, test_type: SkSmartSelfTest, ) -> Result<bool, Errno>

Query the device and return whether or not a particular smart test is supported on it

Source

pub fn execute_smart_self_test( &mut self, test_type: SkSmartSelfTest, ) -> Result<(), Errno>

Source

pub fn smart_get_overall(&mut self) -> Result<SkSmartOverall, Errno>

Source

pub fn identify_parse(&mut self) -> Result<IdentifyParsedData, Errno>

Get the model, firmware, and serial of the disk as a IdentifyParsedDatastruct If Errno::EINVAL gets returned there is a problem with the C string parser

Trait Implementations§

Source§

impl Drop for Disk

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.