liblitho 0.2.0

cli tool to flash/clone the images to storage devices
Documentation
//! Safety rails before destructive block I/O.

use crate::devices::{DeviceError, DeviceMount};

/// Refuse system disks and report busy mounts.
pub trait DeviceSafety {
    /// Refuse the disk that hosts the OS / boot volume.
    fn refuse_system_disk(path: &str) -> Result<(), DeviceError>;

    /// List partitions or volumes on `path` that are currently mounted.
    fn list_mounts(path: &str) -> Result<Vec<DeviceMount>, DeviceError>;

    /// Refuse when any volume on the disk is still mounted.
    fn refuse_if_busy(path: &str) -> Result<(), DeviceError> {
        let mounts = Self::list_mounts(path)?;
        if mounts.is_empty() {
            return Ok(());
        }
        Err(DeviceError::busy(crate::devices::format_device_busy_error(
            path, &mounts,
        )))
    }

    /// Platform-specific busy-error hint line (used by `format_device_busy_error`).
    fn busy_hint() -> &'static str {
        "Unmount all volumes on this drive, then try again."
    }
}