FR-RAW-2 — A decoder trait, so that "without changing callers" is tested #57

Closed
opened 2026-09-19 10:20:53 +00:00 by dtourolle · 1 comment
Owner

dr_decode is reached through free functions and there is one decoder; the clause's "a second implementation may be added without changing callers" is a claim nothing tests. The spec says so itself and has since the clause was rewritten to bytes-in; this is the outstanding half.

Why

D2 keeps LibRaw behind a trait as the fallback for camera coverage rawler lacks, and S7 (never run, #48) is what would say whether that day is near. Introducing the trait after a second decoder exists means changing every caller at the moment there is most pressure not to; introducing it now costs a rename.

Deliverable

  • A Decoder trait over metadata(&[u8]), decode(&[u8], …), preview(&[u8]) and HEADER_BYTES, with the rawler path as its one implementation.
  • Callers take &dyn Decoder or a generic; the free functions become the default's.
  • A test that substitutes a stub decoder and shows the catalog scan, the preview ladder and export unchanged.

Acceptance

  • No path-based or SourceRef-based entry point appears (the property the clause is actually for)
  • The stub-decoder test exists and would fail if a caller named the concrete decoder
  • TRACES: FR-RAW-2 on the trait and the test
**`dr_decode` is reached through free functions and there is one decoder; the clause's "a second implementation may be added without changing callers" is a claim nothing tests.** The spec says so itself and has since the clause was rewritten to bytes-in; this is the outstanding half. ## Why D2 keeps LibRaw behind a trait as the fallback for camera coverage rawler lacks, and S7 (never run, #48) is what would say whether that day is near. Introducing the trait *after* a second decoder exists means changing every caller at the moment there is most pressure not to; introducing it now costs a rename. ## Deliverable - A `Decoder` trait over `metadata(&[u8])`, `decode(&[u8], …)`, `preview(&[u8])` and `HEADER_BYTES`, with the rawler path as its one implementation. - Callers take `&dyn Decoder` or a generic; the free functions become the default's. - A test that substitutes a stub decoder and shows the catalog scan, the preview ladder and export unchanged. ## Acceptance - [ ] No path-based or `SourceRef`-based entry point appears (the property the clause is actually for) - [ ] The stub-decoder test exists and would fail if a caller named the concrete decoder - [ ] `TRACES: FR-RAW-2` on the trait and the test
dtourolle added the pipelinesize:S labels 2026-09-19 10:20:53 +00:00
Author
Owner

Merged to master: d8fb382, 414094b, 733a033.

  • pub trait Decoder in core/dr-decode/src/decoder.rs, taking bytes only: header_bytes, metadata, orientation, locate_preview, preview, decode. Rawler implements it by calling the existing functions, so behaviour is unchanged; dr_decode::default() hands it out.
  • Callers in dr-ui (load, library scan and previews, import, export, merge, repairs) take &dyn Decoder. The default is named only where a job starts.
  • ui/dr-ui/src/decoder_seam.rs hands a stub decoder for a made-up container to the catalog scan, the preview ladder and export, and asserts on values only the stub produces. It was checked to fail when two callers were pointed back at the concrete functions.
  • TRACES: FR-RAW-2; requirements.md now says the trait is built and the LibRaw decoder is not.

Left open: the linear-DNG date fallback (trailing_ifd/metadata_split) still calls the free functions, and the stub test does not cover merge and repairs.

Merged to master: d8fb382, 414094b, 733a033. - `pub trait Decoder` in `core/dr-decode/src/decoder.rs`, taking bytes only: `header_bytes`, `metadata`, `orientation`, `locate_preview`, `preview`, `decode`. `Rawler` implements it by calling the existing functions, so behaviour is unchanged; `dr_decode::default()` hands it out. - Callers in dr-ui (load, library scan and previews, import, export, merge, repairs) take `&dyn Decoder`. The default is named only where a job starts. - `ui/dr-ui/src/decoder_seam.rs` hands a stub decoder for a made-up container to the catalog scan, the preview ladder and export, and asserts on values only the stub produces. It was checked to fail when two callers were pointed back at the concrete functions. - `TRACES: FR-RAW-2`; requirements.md now says the trait is built and the LibRaw decoder is not. Left open: the linear-DNG date fallback (`trailing_ifd`/`metadata_split`) still calls the free functions, and the stub test does not cover merge and repairs.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dtourolle/DarkRoom#57