Skip to main content

ModuleReassembler

Struct ModuleReassembler 

Source
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

Source

pub fn new() -> Self

Source

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).

Source

pub fn with_limits(max_module_size: u32, max_total_bytes: usize) -> Self

New reassembler with explicit per-module and aggregate byte caps.

Source

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).

Source

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.

Source

pub fn pending(&self) -> usize

Number of modules currently being collected.

Source

pub fn pending_bytes(&self) -> usize

Total bytes currently held by in-progress module buffers.

Trait Implementations§

Source§

impl Default for ModuleReassembler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.