Expand description
Format detection and pipeline resolution.
Streams have no filename, so extensions are a hint and never the decision.
resolve_chain is the single-layer resolution: outer format only, with
the inner layer decided from the path’s remaining extensions when one is
given (inner_from_path) and Chain::Raw otherwise. resolve_chain_deep
closes that gap: whenever the outer layer is a codec and the inner layer
is still Chain::Raw — no path at all (stdin), or a path whose
extensions ran out — it decodes that layer, peeks PROBE_LEN of the
decoded bytes, and resolves again — recursively, bounded by
MAX_CHAIN_DEPTH on both routes, so that neither a piped stream nor a
misleadingly-named file can turn re-probing a decoded stream into an
unbounded decompression-nesting attack. Either way the source it returns
is already decoded through every codec layer named in the resolved
Chain, so a caller never has to guess which route produced it.
Enums§
- Chain
- A resolved decode pipeline.
Constants§
- MAX_
CHAIN_ DEPTH - Maximum layers when re-probing a decoded stream.
- PROBE_
LEN - The detection window, per the spec.
Functions§
- chain_
for_ new_ path - The chain an OUTPUT path names, from its extensions alone.
- probe
- Reads a bounded prefix without consuming it.
- resolve_
chain - Turns a path and/or a probed prefix into a concrete pipeline.
- resolve_
chain_ deep resolve_chain, but when the outer layer is a codec whose inner the path left asChain::Raw— whether because there was no path at all, or because the path’s own extensions ran out before naming a container — keeps going: decodes that layer, peeksPROBE_LENof the decoded bytes, and resolves again from the decoded bytes’ own magic. Closes the Phase 0 limitation where a codec on stdin always bottomed out at Raw purely for lack of an extension.- resolve_
chain_ deep_ with resolve_chain_deep, but with theDecodeOptsevery codec layer’s decoder is built from spelled out by the caller instead of defaulted.