Add zstd decompression

This commit is contained in:
Truman Kilen 2023-06-16 15:56:06 -05:00
parent 9974d035b1
commit 08783bff03
3 changed files with 7 additions and 0 deletions

View file

@ -18,6 +18,7 @@ ureq = "2.6.2"
hex-literal = "0.4.1" hex-literal = "0.4.1"
hex = { workspace = true } hex = { workspace = true }
once_cell = "1.17.1" once_cell = "1.17.1"
zstd = "0.12.3"
[dev-dependencies] [dev-dependencies]
base64 = { workspace = true } base64 = { workspace = true }

View file

@ -362,6 +362,11 @@ impl Entry {
None => buf.write_all(&data)?, None => buf.write_all(&data)?,
Some(Compression::Zlib) => decompress!(flate2::read::ZlibDecoder<&[u8]>), Some(Compression::Zlib) => decompress!(flate2::read::ZlibDecoder<&[u8]>),
Some(Compression::Gzip) => decompress!(flate2::read::GzDecoder<&[u8]>), Some(Compression::Gzip) => decompress!(flate2::read::GzDecoder<&[u8]>),
Some(Compression::Zstd) => {
for range in ranges {
io::copy(&mut zstd::stream::read::Decoder::new(&data[range])?, buf)?;
}
}
Some(Compression::Oodle) => { Some(Compression::Oodle) => {
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
return Err(super::Error::Oodle); return Err(super::Error::Oodle);

View file

@ -117,4 +117,5 @@ pub enum Compression {
Zlib, Zlib,
Gzip, Gzip,
Oodle, Oodle,
Zstd,
} }