pub struct DecoderBuilder { /* private fields */ }Expand description
Builder for an immutable, reusable Decoder.
Defaults use std::thread::available_parallelism as the maximum decoder
budget, 4 MiB decoded chunks, 1 MiB positional input pages and compressed
grid spacing, decoder_threads + 2 in-flight chunks, strict gzip framing,
no output limit or exact-size expectation, and no line counting. The defaults favor
throughput; applications with tight memory budgets can
reduce the worker budget, decoded chunk size, or in-flight count.
Implementations§
Source§impl DecoderBuilder
impl DecoderBuilder
Sourcepub const fn decoder_threads(self, threads: usize) -> Self
pub const fn decoder_threads(self, threads: usize) -> Self
Sets the maximum decoder-worker budget.
Individual paths may use fewer active workers when the input exposes less parallelism or when a larger speculative window would reduce throughput through memory pressure.
This also resets the in-flight chunk count to threads + 2. Call
DecoderBuilder::in_flight_chunks afterward to override that value.
Sourcepub const fn decoded_chunk_size(self, bytes: usize) -> Self
pub const fn decoded_chunk_size(self, bytes: usize) -> Self
Sets the target decoded chunk size in bytes.
Larger chunks reduce handoff overhead but can increase per-worker and
queued memory. The value must be non-zero and fit in zlib’s uInt.
Sourcepub const fn input_page_size(self, bytes: usize) -> Self
pub const fn input_page_size(self, bytes: usize) -> Self
Sets the positional input page size in bytes.
The value must be non-zero and fit in zlib’s uInt. A streaming cursor
retains at least two bytes so format detection can span short reads.
Sourcepub const fn compressed_chunk_size(self, bytes: usize) -> Self
pub const fn compressed_chunk_size(self, bytes: usize) -> Self
Sets the target spacing between speculative chunk starts.
The current estimated-grid decoder requires at least 1 MiB to keep its independently discovered boundaries strongly validated.
Sourcepub const fn in_flight_chunks(self, count: usize) -> Self
pub const fn in_flight_chunks(self, count: usize) -> Self
Sets the maximum number of decoded chunks awaiting consumption.
This bounds reader backpressure and ordered-result buffering at the final handoff. The value must be non-zero.
Sourcepub const fn output_limit(self, bytes: Option<u64>) -> Self
pub const fn output_limit(self, bytes: Option<u64>) -> Self
Sets or clears the total decoded-output limit in bytes.
On overflow, decoding returns DecodeError::OutputLimitExceeded
before emitting bytes beyond the limit. Output already emitted remains
visible to the caller.
Sourcepub const fn expected_uncompressed_size(self, bytes: Option<u64>) -> Self
pub const fn expected_uncompressed_size(self, bytes: Option<u64>) -> Self
Requires exactly bytes of decoded output, or clears the expectation.
Unlike Self::output_limit, this is both an upper and lower bound.
An overrun is rejected before the offending chunk is emitted, and an
underrun is rejected after the selected container is complete.
Sourcepub const fn count_lines(self, enabled: bool) -> Self
pub const fn count_lines(self, enabled: bool) -> Self
Enables or disables counting newline bytes in the decoded output.
The final count is returned through DecodeReport::line_count. When
an index is collected by the same operation, every retained checkpoint
is also annotated with the number of preceding newlines and the index
records the total. This metadata enables
crate::IndexedReader::seek_to_line and gztool version 1 export.
Counting is disabled by default. When disabled, output is not scanned and reports and newly built indexes carry no line metadata.
Sourcepub const fn format(self, format: Format) -> Self
pub const fn format(self, format: Format) -> Self
Selects the container framing explicitly.
The default is Format::Gzip, preserving strict gzip behavior.
Select Format::RawDeflate explicitly because an unwrapped stream has
no magic bytes and is never safe to guess.
Sourcepub const fn auto_detect_format(self) -> Self
pub const fn auto_detect_format(self) -> Self
Detects gzip or zlib framing from an exact two-byte prefix.
Raw DEFLATE is never auto-detected. An unrecognized prefix produces
DecodeError::UnrecognizedFormat.
Sourcepub fn build(self) -> Result<Decoder, ConfigError>
pub fn build(self) -> Result<Decoder, ConfigError>
Validates the configuration and creates a reusable decoder.
§Errors
Returns ConfigError when a size or count violates the constraints
documented on its setter.
Trait Implementations§
Source§impl Clone for DecoderBuilder
impl Clone for DecoderBuilder
Source§fn clone(&self) -> DecoderBuilder
fn clone(&self) -> DecoderBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more