Skip to main content

Module section_reader

Module section_reader 

Source
Expand description

Bounded, seekable windows over a shared source. Bounded, seekable windows over a shared source.

Lazy archive indexes read entry bytes on demand rather than slurping a whole file, so several of them need to read from one open handle at independent positions. SectionReader is that primitive: a (start, len) window that presents itself as a standalone stream starting at zero.

Two properties earn its place:

  • Handles are shared through a Mutex, not try_clone. Cloned file descriptors share one OS seek cursor, so two readers walking the same file would silently corrupt each other’s positions. Each window keeps its own logical position and seeks the shared handle immediately before every read.
  • Windows nest. SectionReader::section carves a sub-window out of an existing one against the same handle, which is what lets an archive index open a nested archive stored at an offset inside its parent. A save game is exactly this shape: per-module archives living at offsets inside SAVEGAME.sav.

Structs§

SectionReader
A bounded window over a shared seekable source.