Crate autocompress

source ·
Expand description

autocompress

A library for reading and writing compressed files with async support and automatic format detection.

Feature flags

  • gzip : Gzip format support
  • bgzip : bgzip format support
  • bzip2 : Bzip2 format support
  • xz : XZ format support
  • zstd : Zstd format support
  • rayon : Off-load compression and decompression process to another thread using rayon
  • tokio : Async reader and writer support with tokio
  • tokio_fs: Enable autodetect_async_open function

Migration from previous versions

This version drops supports of some formats, such as snappy, lz4 and brotli. Names of functions are also changed. Please replace following functions to migrate from previous versions.

Example

Read from a file

use autocompress::autodetect_open;

let mut reader = autodetect_open("testfiles/pg2701.txt.xz")?;
let mut buf = Vec::new();
reader.read_to_end(&mut buf)?;

Write to a file

use autocompress::{autodetect_create, CompressionLevel};

let mut writer = autodetect_create("target/doc-index.xz", CompressionLevel::Default)?;
writer.write_all(&b"Hello, world\n"[..])?;

Parallel Compression

use autocompress::{autodetect_parallel_create, CompressionLevel};

let mut writer = autodetect_parallel_create("target/doc-index2.xz", CompressionLevel::Default)?;
writer.write_all(&b"Hello, world\n"[..])?;

Modules

  • bgzipbgzip
    bgzip format support
  • bzip2bzip2
    Bzip2 format support
  • gzipgzip
    gzip format support
  • Reader and Writer implementations for Processor
  • xzxz
    XZ format support
  • zlibgzip
    Zlib format support
  • zstdzstd
    Zstandard format support

Structs

Enums

  • Compression level for compress processors
  • Error type for this crate
  • File Format
  • Values which indicate the form of flushing to be used when processing data.
  • Processed status

Traits

Functions

Type Aliases

  • Result type for this crate