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
- io
- Reader and Writer implementations for
Processor
- xz
xz
- XZ format support
- zlib
gzip
- Zlib format support
- zstd
zstd
- Zstandard format support
Structs§
- Plain
Processor - Pass-through processor
Enums§
- Compression
Level - Compression level for compress processors
- Error
- Error type for this crate
- File
Format - 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_ reader tokio
- Automatically select suitable decoder from magic number from
AsyncBufRead
. - autodetect_
async_ create tokio_fs
- Create a file, and automatically select a suitable encoder from file extension, async version.
- autodetect_
async_ create_ or_ stdout tokio_fs
- Create a file or open standard input, and automatically select a suitable encoder from file extension, async version.
- autodetect_
async_ open tokio_fs
- Open a file and automatically select a suitable decoder from magic number.
- autodetect_
async_ open_ or_ stdin tokio_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_ bgzip bgzip
- Create a file or open standard input, and automatically select a suitable encoder from file extension.
- autodetect_
create_ prefer_ bgzip bgzip
- 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_ create rayon
- 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_ stdout rayon
- 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