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
io
Reader and Writer implementations for Processor
xzxz
XZ format support
zlibgzip
Zlib format support
zstdzstd
Zstandard format support

Structs§

PlainProcessor
Pass-through processor

Enums§

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

Traits§

Processor
Process in-memory stream of data.

Functions§

autodetect_async_buf_readertokio
Automatically select suitable decoder from magic number from AsyncBufRead.
autodetect_async_createtokio_fs
Create a file, and automatically select a suitable encoder from file extension, async version.
autodetect_async_create_or_stdouttokio_fs
Create a file or open standard input, and automatically select a suitable encoder from file extension, async version.
autodetect_async_opentokio_fs
Open a file and automatically select a suitable decoder from magic number.
autodetect_async_open_or_stdintokio_fs
Open a file or standard input, and automatically select suitable decoder from magic number.
autodetect_buf_reader
Automatically select suitable decoder from magic number from BufRead.
autodetect_create
Create a file and automatically select a suitable encoder from file extension.
autodetect_create_or_stdout
Create a file or open standard input, and automatically select a suitable encoder from file extension.
autodetect_create_or_stdout_prefer_bgzipbgzip
Create a file or open standard input, and automatically select a suitable encoder from file extension.
autodetect_create_prefer_bgzipbgzip
Create a file and automatically select a suitable encoder from file extension.
autodetect_open
Open a file and automatically select a suitable decoder from magic number.
autodetect_open_or_stdin
Open a file or standard input, and automatically select suitable decoder from magic number.
autodetect_parallel_createrayon
Creates a new ParallelCompressWriter with a file at the specified path and the specified compression level. The file format is auto-detected based on the file extension.
autodetect_parallel_create_or_stdoutrayon
Creates a new ParallelCompressWriter with a file at the specified path or standard output and the specified compression level. The file format is auto-detected based on the file extension.
autodetect_reader
Automatically select suitable decoder from magic number from Read.

Type Aliases§

Result
Result type for this crate