Skip to main content

PositionalBlockDecoder

Struct PositionalBlockDecoder 

Source
pub struct PositionalBlockDecoder { /* private fields */ }
Expand description

An owned block decode that can move to a caller’s worker pool.

Every decode owns an independent positional cursor. The archive and password are shared without cloning their contents; sharing the same Arc<Password> also shares its lifetime KDF budget and derived-key cache. No worker is spawned until a codec’s explicitly requested thread count requires one.

The source must provide the same archive image that was parsed. A streaming consumer is responsible for admitting only covered packed ranges and for invalidating or cancelling work when those bytes are replaced by repair. Callback errors stop the decode and pass through unchanged, as they do for BlockDecoder. Codec workers are joined when their decode stack drops.

Implementations§

Source§

impl PositionalBlockDecoder

Source

pub fn new( archive: Arc<Archive>, password: Arc<Password>, source: Arc<dyn ReadAt>, block_index: usize, ) -> Result<Self, Error>

Prepares one block over a parsed archive and an independent cursor.

Defaults to one codec thread and checksum verification. This allocates no decoder dictionary and reads no packed bytes until the entry walk.

§Errors

Returns an error if block_index is outside the parsed archive or its data members are interspersed with no-stream entries. The latter cannot be represented by the underlying block walk and requires another path.

Source

pub fn with_limits( archive: Arc<Archive>, password: Arc<Password>, source: Arc<dyn ReadAt>, block_index: usize, limits: ArchiveLimits, ) -> Result<Self, Error>

As Self::new, enforcing the same decoder and KDF limits as BlockDecoder::with_limits. Concurrent decodes each obey these limits; the caller must also bound their combined memory and worker count.

§Errors

As Self::new.

Source

pub fn set_threads(&mut self, threads: u32)

Sets this block’s codec thread count, clamped to 1..=256.

Source

pub fn with_threads(self, threads: u32) -> Self

Self::set_threads for a builder chain.

Source

pub fn with_adaptive_lzma2(self) -> Self

Enables later LZMA2 widening through Self::lzma2_handle.

Source

pub fn with_verify_checksums(self, verify: bool) -> Self

Controls checksum verification, as on BlockDecoder.

Source

pub fn lzma2_handle(&self) -> Lzma2Handle

Returns the control handle that remains usable while this decode runs.

Source

pub fn set_sub_stream_complete_hook( &mut self, hook: impl FnMut(SubStreamCompletion) + Send + 'static, )

Installs the verified sub-stream completion hook for this block. Hooks run on the thread executing the entry walk, in file order.

Source

pub fn entries(&self) -> &[ArchiveEntry]

Entries in this block, in archive order.

Source

pub fn for_each_entries<F>(self, each: &mut F) -> Result<bool, Error>
where F: FnMut(&ArchiveEntry, &mut dyn Read) -> Result<bool, Error>,

Decodes on the calling thread, with ordinary Read callbacks. Returns false when a callback stops the walk early.

§Errors

The same located codec/checksum errors and unchanged callback errors as BlockDecoder::for_each_entries.

Source

pub fn for_each_entries_direct<F>(self, each: &mut F) -> Result<bool, Error>
where F: FnMut(&ArchiveEntry, &mut dyn EntryRead) -> Result<bool, Error>,

Decodes on the calling thread with direct output delivery.

§Errors

As Self::for_each_entries.

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.