v0.20.1: delete SectorReader, extract Disc::patch, doc/stub cleanup

WO-2 (delete SectorReader trait):
- The 0.18 trait split into SectorSource (read-only) and SectorSink
  (write-only) is final; the legacy SectorReader alias was a bridge.
- Renames every internal &mut dyn SectorReader (~25 sites) to
  &mut dyn SectorSource. The trait method capacity() becomes
  capacity_sectors() with a default of 0 (preserves SectorReader's
  default-0 behavior).
- Deletes the SectorReader trait, its blanket-to-Source bridge, and
  the FileSectorReader type alias. Adds explicit forwarding impls
  for Box<dyn SectorSource> and &mut dyn SectorSource so generic
  decorators like DecryptingSectorSource<S: SectorSource> compose.

WO-3a (extract Disc::patch):
- Moves Disc::patch (1230 lines) and bytes_bad_in_title from
  disc/mod.rs into disc/patch.rs as a split inherent impl. Zero
  behavior change — pure mechanical relocation. disc/mod.rs drops
  from 3,945 to 2,714 LOC.

WO-6 (partial):
- Deletes src/labels/png_filenames.rs — was a 72-LOC stub with
  detect() returning false, never wired into the PARSERS registry.

CLAUDE.md doc drift fixes (audited 2026-05-13):
- JUMP_BASE_SECTORS: 256→1024 (64 MB base for UHD, not 8 MB)
- PASSN_DAMAGE_THRESHOLD_PCT: 12→6
- PASSN_SKIP_SECTORS_BASE: 64→32
- MAX_RANGE_SECS=180: replaced by proportional range_sectors × 25,
  capped at RANGE_BUDGET_CAP_SECS=1800.
This commit is contained in:
2026-05-13 11:36:55 -07:00
parent 1018dcf698
commit 6f9e297a9e
35 changed files with 1447 additions and 1601 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
//! Disc scanning pipeline tests.
use libfreemkv::SectorReader;
use libfreemkv::SectorSource;
use libfreemkv::error::Result;
use libfreemkv::{Disc, DiscTitle, ScanOptions};
use std::collections::HashMap;
@@ -20,7 +20,7 @@ impl MockSectorReader {
}
}
impl SectorReader for MockSectorReader {
impl SectorSource for MockSectorReader {
fn read_sectors(
&mut self,
lba: u32,
+17 -13
View File
@@ -5,8 +5,8 @@ use libfreemkv::disc::{CopyOptions, DiscRegion};
use libfreemkv::error::Result;
use libfreemkv::pes::Stream as PesStream;
use libfreemkv::{
ContentFormat, Disc, DiscFormat, DiscStream, DiscTitle, EventKind, Extent, FileSectorReader,
SectorReader,
ContentFormat, Disc, DiscFormat, DiscStream, DiscTitle, EventKind, Extent, FileSectorSource,
SectorSource,
};
use std::io::Write;
use std::sync::Arc;
@@ -32,7 +32,7 @@ impl ZeroSectorReader {
}
}
impl SectorReader for ZeroSectorReader {
impl SectorSource for ZeroSectorReader {
fn read_sectors(
&mut self,
_lba: u32,
@@ -46,7 +46,7 @@ impl SectorReader for ZeroSectorReader {
Ok(bytes)
}
fn capacity(&self) -> u32 {
fn capacity_sectors(&self) -> u32 {
self.capacity
}
}
@@ -67,7 +67,7 @@ impl SlowZeroSectorReader {
}
}
impl SectorReader for SlowZeroSectorReader {
impl SectorSource for SlowZeroSectorReader {
fn read_sectors(
&mut self,
_lba: u32,
@@ -81,7 +81,7 @@ impl SectorReader for SlowZeroSectorReader {
Ok(bytes)
}
fn capacity(&self) -> u32 {
fn capacity_sectors(&self) -> u32 {
self.capacity
}
}
@@ -304,7 +304,7 @@ fn test_drop_impls_do_not_panic_or_block() {
panic!("DiscStream drop did not complete within 100ms");
}
// ── 5. FileSectorReader round trip ────────────────────────────────────────
// ── 5. FileSectorSource round trip ────────────────────────────────────────
#[test]
fn test_file_sector_reader_round_trip() {
@@ -321,9 +321,13 @@ fn test_file_sector_reader_round_trip() {
tmp.flush().expect("flush");
let path = tmp.path().to_path_buf();
let mut fsr = FileSectorReader::open(&path).expect("open FileSectorReader");
let mut fsr = FileSectorSource::open(&path).expect("open FileSectorSource");
assert_eq!(fsr.capacity(), N_SECTORS as u32, "capacity mismatch");
assert_eq!(
fsr.capacity_sectors(),
N_SECTORS as u32,
"capacity mismatch"
);
// Read each sector individually and compare.
let mut buf = vec![0u8; SECTOR_SIZE];
@@ -391,7 +395,7 @@ impl FailingSectorReader {
}
}
impl SectorReader for FailingSectorReader {
impl SectorSource for FailingSectorReader {
fn read_sectors(
&mut self,
_lba: u32,
@@ -418,7 +422,7 @@ impl SectorReader for FailingSectorReader {
})
}
fn capacity(&self) -> u32 {
fn capacity_sectors(&self) -> u32 {
self.capacity
}
}
@@ -567,7 +571,7 @@ struct BlockSizeFailingReader {
capacity: u32,
}
impl SectorReader for BlockSizeFailingReader {
impl SectorSource for BlockSizeFailingReader {
fn read_sectors(
&mut self,
lba: u32,
@@ -593,7 +597,7 @@ impl SectorReader for BlockSizeFailingReader {
}
}
fn capacity(&self) -> u32 {
fn capacity_sectors(&self) -> u32 {
self.capacity
}
}
+3 -3
View File
@@ -15,7 +15,7 @@ use libfreemkv::disc::CopyOptions;
use libfreemkv::disc::DiscRegion;
use libfreemkv::disc::mapfile::{Mapfile, SectorStatus};
use libfreemkv::error::Result;
use libfreemkv::{ContentFormat, Disc, DiscFormat, SectorReader};
use libfreemkv::{ContentFormat, Disc, DiscFormat, SectorSource};
use std::collections::HashSet;
use std::sync::{Arc, Mutex};
@@ -46,7 +46,7 @@ impl PatternedSectorReader {
}
}
impl SectorReader for PatternedSectorReader {
impl SectorSource for PatternedSectorReader {
fn read_sectors(
&mut self,
lba: u32,
@@ -82,7 +82,7 @@ impl SectorReader for PatternedSectorReader {
Ok(buf.len())
}
fn capacity(&self) -> u32 {
fn capacity_sectors(&self) -> u32 {
self.capacity
}
}
+4 -4
View File
@@ -1,7 +1,7 @@
//! UDF parser tests using a MockSectorReader.
use libfreemkv::error::Result;
use libfreemkv::{SectorReader, read_filesystem};
use libfreemkv::{SectorSource, read_filesystem};
use std::collections::HashMap;
const SECTOR_SIZE: usize = 2048;
@@ -38,7 +38,7 @@ impl MockSectorReader {
}
}
impl SectorReader for MockSectorReader {
impl SectorSource for MockSectorReader {
fn read_sectors(
&mut self,
lba: u32,
@@ -463,11 +463,11 @@ fn find_dir_case_insensitive() {
#[test]
fn sector_reader_is_object_safe() {
// Verify SectorReader can be used as a trait object
// Verify SectorSource can be used as a trait object
let mut reader = MockSectorReader::new();
reader.set_sector(0, vec![42u8; SECTOR_SIZE]);
let dyn_reader: &mut dyn SectorReader = &mut reader;
let dyn_reader: &mut dyn SectorSource = &mut reader;
let mut buf = vec![0u8; SECTOR_SIZE];
let n = dyn_reader.read_sectors(0, 1, &mut buf, true).unwrap();
assert_eq!(n, SECTOR_SIZE);