drive: select the platform module once, not per function
find_drives and resolve_device each carried a three-arm cfg(target_os) block in their bodies. Alias the current platform's module once (`use linux as platform` under a single cfg) and let both dispatch through `platform::…`, so the function bodies are cfg-free and a new entry point cannot forget an arm.
This commit is contained in:
+16
-24
@@ -35,6 +35,15 @@ pub(crate) mod macos;
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub(crate) mod windows;
|
pub(crate) mod windows;
|
||||||
|
|
||||||
|
// Pick the platform module ONCE, here, so the cross-platform entry points below
|
||||||
|
// dispatch through `platform::…` with no per-function `#[cfg]` in their bodies.
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
pub(crate) use linux as platform;
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
pub(crate) use macos as platform;
|
||||||
|
#[cfg(windows)]
|
||||||
|
pub(crate) use windows as platform;
|
||||||
|
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
use crate::event::Event;
|
use crate::event::Event;
|
||||||
use crate::identity::DriveId;
|
use crate::identity::DriveId;
|
||||||
@@ -1385,18 +1394,7 @@ fn sleep_until_halted(halt: &AtomicBool, total: std::time::Duration) -> Result<(
|
|||||||
|
|
||||||
/// Internal: discover drive paths + IDs without opening full Drive objects.
|
/// Internal: discover drive paths + IDs without opening full Drive objects.
|
||||||
fn discover_drives() -> Vec<(String, DriveId)> {
|
fn discover_drives() -> Vec<(String, DriveId)> {
|
||||||
#[cfg(target_os = "linux")]
|
platform::find_drives()
|
||||||
{
|
|
||||||
linux::find_drives()
|
|
||||||
}
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
{
|
|
||||||
macos::find_drives()
|
|
||||||
}
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
windows::find_drives()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Structured outcome of [`resolve_device`] — a machine-readable signal
|
/// Structured outcome of [`resolve_device`] — a machine-readable signal
|
||||||
@@ -1416,20 +1414,14 @@ pub enum DeviceResolution {
|
|||||||
/// Resolve a device path to its raw SCSI device. Returns the resolved
|
/// Resolve a device path to its raw SCSI device. Returns the resolved
|
||||||
/// path plus a structured [`DeviceResolution`] signal describing whether
|
/// path plus a structured [`DeviceResolution`] signal describing whether
|
||||||
/// any substitution happened; the application layer maps that to UX text.
|
/// any substitution happened; the application layer maps that to UX text.
|
||||||
|
///
|
||||||
|
/// Staged, not yet wired: the cross-platform dispatch is kept ready for the
|
||||||
|
/// caller that will consume it, so the per-platform implementations below it
|
||||||
|
/// (and their tests) stay live. `allow(dead_code)` marks that deliberately —
|
||||||
|
/// this is not an accidental orphan.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(crate) fn resolve_device(path: &str) -> Result<(String, DeviceResolution)> {
|
pub(crate) fn resolve_device(path: &str) -> Result<(String, DeviceResolution)> {
|
||||||
#[cfg(target_os = "linux")]
|
platform::resolve_device(path)
|
||||||
{
|
|
||||||
linux::resolve_device(path)
|
|
||||||
}
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
{
|
|
||||||
macos::resolve_device(path)
|
|
||||||
}
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
windows::resolve_device(path)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
Reference in New Issue
Block a user