MCPcopy Create free account
hub / github.com/archlinux/alpm / new

Method new

alpm-compress/src/decompression/decoder.rs:47–57  ·  view source on GitHub ↗

Creates a new [`CompressionDecoder`]. Uses a [`File`] to stream from and initializes a specific backend based on the provided [`DecompressionSettings`]. # Errors Returns an error if creating the decoder for zstd compression fails (all other decoder initializations are infallible).

(file: File, settings: DecompressionSettings)

Source from the content-addressed store, hash-verified

45 /// Returns an error if creating the decoder for zstd compression fails
46 /// (all other decoder initializations are infallible).
47 pub fn new(file: File, settings: DecompressionSettings) -> Result<Self, Error> {
48 match settings {
49 DecompressionSettings::Bzip2 => Ok(Self::Bzip2(BzDecoder::new(BufReader::new(file)))),
50 DecompressionSettings::Gzip => Ok(Self::Gzip(GzDecoder::new(BufReader::new(file)))),
51 DecompressionSettings::Xz => Ok(Self::Xz(XzDecoder::new(BufReader::new(file)))),
52 DecompressionSettings::Zstd => Ok(Self::Zstd(
53 Decoder::new(file).map_err(Error::CreateZstandardDecoder)?,
54 )),
55 DecompressionSettings::None => Ok(Self::None(BufReader::new(file))),
56 }
57 }
58}
59
60impl Debug for CompressionDecoder<'_> {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected