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 supportbgzip
: bgzip format supportbzip2
: Bzip2 format supportxz
: XZ format supportzstd
: Zstd format supportrayon
: Off-load compression and decompression process to another thread using rayontokio
: Async reader and writer support with tokiotokio_fs
: Enableautodetect_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.
create
->autodetect_create
open
->autodetect_open
create_or_stdout
->autodetect_create_or_stdout
open_or_stdin
->autodetect_open_or_stdin
suggest_format
->FileFormat::from_buf_reader
suggest_format_from_path
->FileFormat::from_path
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
- bgzip
bgzip
bgzip format support - bzip2
bzip2
Bzip2 format support - gzip
gzip
gzip format support - Reader and Writer implementations for
Processor
- xz
xz
XZ format support - zlib
gzip
Zlib format support - zstd
zstd
Zstandard format support
Structs
- Pass-through processor
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
- Process in-memory stream of data.
Functions
- Automatically select suitable decoder from magic number from
AsyncBufRead
. - Create a file, and automatically select a suitable encoder from file extension, async version.
- Create a file or open standard input, and automatically select a suitable encoder from file extension, async version.
- Open a file and automatically select a suitable decoder from magic number.
- Open a file or standard input, and automatically select suitable decoder from magic number.
- Automatically select suitable decoder from magic number from
BufRead
. - Create a file and automatically select a suitable encoder from file extension.
- Create a file or open standard input, and automatically select a suitable encoder from file extension.
- Create a file or open standard input, and automatically select a suitable encoder from file extension.
- Create a file and automatically select a suitable encoder from file extension.
- Open a file and automatically select a suitable decoder from magic number.
- Open a file or standard input, and automatically select suitable decoder from magic number.
- 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. - 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. - Automatically select suitable decoder from magic number from
Read
.
Type Aliases
- Result type for this crate