liblitho 0.2.0

cli tool to flash/clone the images to storage devices
Documentation
//! Prepare media for exclusive raw disk access.

use crate::devices::DeviceError;

/// Unmount/dismount volumes and hold exclusive access where required.
pub trait VolumeOps {
    /// RAII guard: Windows volume locks; Linux usually unit.
    type Guard: Send;

    /// Prepare `path` for exclusive raw I/O and return a guard that must outlive
    /// the write handle (Windows). Linux returns `()`.
    ///
    /// When `auto_unmount` is false and volumes are mounted, returns
    /// [`DeviceError::Busy`].
    fn prepare_for_io(path: &str, auto_unmount: bool) -> Result<Self::Guard, DeviceError>;

    /// Unmount every volume on `path`. Requires elevated privileges on most OSes.
    fn unmount_volumes(path: &str) -> Result<Vec<String>, DeviceError>;

    /// CLI/TUI preflight: refuse busy disks or unmount, **without** holding a
    /// long-lived exclusive session (Windows locks are taken in [`Self::prepare_for_io`]
    /// when the writer opens).
    fn preflight_for_io(path: &str, auto_unmount: bool) -> Result<(), DeviceError> {
        // Default: prepare then drop guard (correct when Guard is unit, e.g. Linux).
        let _guard = Self::prepare_for_io(path, auto_unmount)?;
        let _ = _guard;
        Ok(())
    }
}