#zlib #zstd #gzip #xz #bzip2

deko

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

6 releases (breaking)

0.6.0 Jan 8, 2026
0.5.0 May 4, 2025
0.4.0 Dec 31, 2024
0.3.0 Dec 17, 2024
0.1.0 Nov 11, 2024

#225 in Compression

Download history 128/week @ 2025-10-14 176/week @ 2025-10-21 75/week @ 2025-10-28 211/week @ 2025-11-04 76/week @ 2025-11-11 110/week @ 2025-11-18 117/week @ 2025-11-25 36/week @ 2025-12-02 180/week @ 2025-12-09 94/week @ 2025-12-16 47/week @ 2025-12-23 108/week @ 2025-12-30 157/week @ 2026-01-06 133/week @ 2026-01-13 105/week @ 2026-01-20 58/week @ 2026-01-27

486 downloads per month
Used in 4 crates (3 directly)

MIT license

67KB
1.5K SLoC

deko

Crates.io Version Docs dependency status

Deko icon.

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

~9MB
~126K SLoC