#bzip2 #xz #zstd #zlib #gzip

deko

A decoder that automatically detects compression format (gzip, bzip2, xz, zstd) via external crates. Includes an encoder for the same formats as well.

3 releases (breaking)

new 0.3.0 Dec 17, 2024
0.2.0 Dec 17, 2024
0.1.0 Nov 11, 2024

#350 in Compression

Download history 114/week @ 2024-11-11 13/week @ 2024-11-18 19/week @ 2024-11-25 121/week @ 2024-12-02 142/week @ 2024-12-09

299 downloads per month
Used in 2 crates (via zar)

MIT license

56KB
1.5K SLoC

deko

Crates.io Version Docs dependency status

A decoder that automatically detects compression format (gzip, bzip2, xz, zstd) via external crates. Includes an encoder for the same formats as well.

Introduction

deko is a library that offers AnyDecoder and AnyEcnoder structs that can decompress/compress the data from/to a variaty formats via the corresponding crates. The format is automatically detected via magic bytes — signatures at the start of the file.

Currently the following formats are supported:

Unused formats can be disabled via crate's features. By default all formats are enabled.

Examples

use deko::Format;
use deko::bufread::AnyDecoder;
use deko::write::{AnyEncoder, Compression};
use std::io::Read;
use std::io::Write;

let mut writer = AnyEncoder::new(Vec::new(), Format::Gz, Compression::Best).unwrap();
writer.write_all(b"Hello world").unwrap();
let compressed_data = writer.finish().unwrap();
let mut reader = AnyDecoder::new(&compressed_data[..]);
let mut string = String::new();
reader.read_to_string(&mut string);
assert_eq!("Hello world", string);

Dependencies

~6MB
~101K SLoC