Skip to main content

DecoderBuilder

Struct DecoderBuilder 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> DecoderBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DecoderBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DecoderBuilder

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.