pub struct ModuleReassembler { /* private fields */ }Expand description
Collects DDB blocks into complete modules.
Usage: call note_dii for every DII (repeats are
idempotent; a changed moduleVersion restarts that module), then feed
every DDB through feed_ddb. DDBs for modules not yet
announced by a DII are ignored — carousels repeat, so the block comes
round again after the DII has been seen.
Memory bounds: each announced module is capped at max_module_size, and
the aggregate of all in-progress module buffers at max_total_bytes —
announcements that would exceed the budget are skipped until completed
modules free space. Block tracking is a bitset (~moduleSize/blockSize/8
bytes), so the worst-case overhead for a blockSize = 1 announcement is
~12.5% on top of the data buffer.
Implementations§
Source§impl ModuleReassembler
impl ModuleReassembler
Sourcepub fn new() -> Self
pub fn new() -> Self
New reassembler with DEFAULT_MAX_MODULE_SIZE and
DEFAULT_MAX_TOTAL_BYTES.
Sourcepub fn with_max_module_size(max_module_size: u32) -> Self
pub fn with_max_module_size(max_module_size: u32) -> Self
New reassembler with a custom per-module size cap (aggregate budget
stays at DEFAULT_MAX_TOTAL_BYTES).
Sourcepub fn with_limits(max_module_size: u32, max_total_bytes: usize) -> Self
pub fn with_limits(max_module_size: u32, max_total_bytes: usize) -> Self
New reassembler with explicit per-module and aggregate byte caps.
Sourcepub fn note_dii(&mut self, dii: &Dii<'_>)
pub fn note_dii(&mut self, dii: &Dii<'_>)
Register the modules announced by a DII. Skipped: modules over the
per-module cap, blockSize == 0, and modules that would push the
aggregate budget over max_total_bytes. Re-announcement of an
in-progress (same-version) module is a no-op; a new version replaces
the old slot (freeing its budget first).
Sourcepub fn feed_ddb(&mut self, ddb: &DownloadDataBlock<'_>) -> Option<Module>
pub fn feed_ddb(&mut self, ddb: &DownloadDataBlock<'_>) -> Option<Module>
Feed one DDB. Returns the completed Module when this block was the
last missing piece. Blocks for unknown (downloadId, moduleId, version)
triples, out-of-range block numbers, repeats, and blocks whose length
disagrees with the DII geometry are ignored.
Sourcepub fn pending_bytes(&self) -> usize
pub fn pending_bytes(&self) -> usize
Total bytes currently held by in-progress module buffers.