#zstd #gzip #zlib #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.

4 releases (breaking)

0.4.0 Dec 31, 2024
0.3.0 Dec 17, 2024
0.2.0 Dec 17, 2024
0.1.0 Nov 11, 2024

#494 in Compression

Download history 91/week @ 2024-11-06 28/week @ 2024-11-13 12/week @ 2024-11-20 66/week @ 2024-11-27 126/week @ 2024-12-04 337/week @ 2024-12-11 298/week @ 2024-12-18 235/week @ 2024-12-25 283/week @ 2025-01-01 249/week @ 2025-01-08 197/week @ 2025-01-15 88/week @ 2025-01-22 123/week @ 2025-01-29 204/week @ 2025-02-05 323/week @ 2025-02-12

792 downloads per month
Used in 3 crates (2 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

~6MB
~102K SLoC