Skip to main content

decode_reader

Function decode_reader 

Source
pub fn decode_reader<'a, R: Read + 'a>(
    codec: &dyn Codec,
    r: R,
    o: &DecodeOpts,
) -> Result<Box<dyn Source + 'a>>
Expand description

Decodes r with codec, borrowing r for as long as the decoder lives.

The one-call route for a caller holding a codec and a reader — notably an archive member’s reader, which is neither 'static nor Send. Needs no registry. A codec that cannot decode is refused with the same Error::CapabilityUnavailable Registry::require_decoder raises (exit 3).

Errors come back already classified, as on every other decode path: an io::Error from the decoder’s construction is folded through Error::from_decode_io, and the returned source is a DecodeSideSource, so a malformed member read through it and converted with a bare ? is the same Error::Corrupt (exit 5) as anywhere else, while a failure of r itself (a disk, a permission) stays Error::Io.