v0.11.16: API cleanup — one method per action

This commit is contained in:
Matt Jackson
2026-04-21 19:17:50 +00:00
parent 8843833ea7
commit 40ec1e1eba
18 changed files with 83 additions and 99 deletions
+11 -13
View File
@@ -10,23 +10,15 @@ use crate::error::Result;
pub trait SectorReader: Send {
/// Read `count` sectors starting at `lba` into `buf`.
/// `buf` must be at least `count * 2048` bytes.
/// Full recovery enabled (retry + reset on failure).
fn read_sectors(&mut self, lba: u32, count: u16, buf: &mut [u8]) -> Result<usize>;
/// Read with explicit recovery flag.
/// true = full retry/reset loop (for ripping). false = single attempt, fast fail (for verify).
/// Default: delegates to read_sectors (recovery=true behavior).
fn read_sectors_recover(
/// `recovery`: true = full retry/reset loop (ripping), false = single attempt (verify).
/// File-backed readers ignore the flag.
fn read_sectors(
&mut self,
lba: u32,
count: u16,
buf: &mut [u8],
recovery: bool,
) -> Result<usize> {
// Default ignores flag — file-backed readers don't have recovery
let _ = recovery;
self.read_sectors(lba, count, buf)
}
) -> Result<usize>;
/// Total capacity in sectors, if known.
fn capacity(&self) -> u32 {
@@ -61,7 +53,13 @@ impl FileSectorReader {
}
impl SectorReader for FileSectorReader {
fn read_sectors(&mut self, lba: u32, count: u16, buf: &mut [u8]) -> Result<usize> {
fn read_sectors(
&mut self,
lba: u32,
count: u16,
buf: &mut [u8],
_recovery: bool,
) -> Result<usize> {
use std::io::{Read, Seek, SeekFrom};
let offset = lba as u64 * 2048;
let bytes = count as usize * 2048;