use crate::devices::{DeviceError, DeviceMount};
pub trait DeviceSafety {
fn refuse_system_disk(path: &str) -> Result<(), DeviceError>;
fn list_mounts(path: &str) -> Result<Vec<DeviceMount>, DeviceError>;
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,
)))
}
fn busy_hint() -> &'static str {
"Unmount all volumes on this drive, then try again."
}
}