pub struct DecodeOpts {
pub threads: Option<usize>,
pub governor: Option<Arc<Governor>>,
pub memory_limit: Option<u64>,
pub fidelity: FidelitySink,
}Expand description
What a codec’s decoder is opened with.
Clones share one FidelitySink. Clone
copies the fidelity handle, not the warnings behind
it, so every clone of one value — and every decoder opened with any of
them — records into the same sink. Reusing one DecodeOpts (or clones of
it) across independent decodes therefore accumulates their warnings
together until the sink is drained; give each decode whose fidelity is
reported on its own a fresh value (DecodeOpts::default(), or a new
sink in fidelity).
Fields§
§threads: Option<usize>Worker hint. The governor has final say; this is only a request.
governor: Option<Arc<Governor>>The shared worker/memory budget. None means single-threaded — a codec
parallelises only if handed a governor, never from an ambient global.
memory_limit: Option<u64>Cap on memory a decoder may ask the allocator for. None means
unbounded, which is the library default; the CLI always sets a value.
This exists because three pure codecs size a dictionary buffer from a
value the file declares in its own header, before producing any
output — measured at 69.35 MB peak RSS for a 60-byte .xz, and 538 MB
for a crafted 114-byte .lz that decoded correctly, so the cost came
purely from the declaration. --max-ratio cannot see it: that guard
counts decoded output bytes and the allocation precedes any output.
Exceeding it is crate::Error::ResourceLimit (exit 6), never
Corrupt (exit 5) — the file is not damaged, this build simply will
not allocate that much.
fidelity: FidelitySinkWhere the decoder records what it approximated — today, bytes after a
gzip or bzip2 file’s last verified member that are neither another
member nor padding (crate::Fidelity::TrailingDataIgnored). The
default is a fresh, empty sink; a driver that reports fidelity keeps a
clone and drains it into its report once the stream has been read.
Shared by every clone of this value (see the type’s doc). See
crate::FidelitySink.