zopen

Crates.iozopen
lib.rszopen
version1.0.0
sourcesrc
created_at2018-09-26 12:06:25.479976
updated_at2024-01-17 09:23:43.198752
descriptionAutomatically open compressed files.
homepagehttps://chiselapp.com/user/fifr/repository/zopen
repositoryhttps://chiselapp.com/user/fifr/repository/zopen
max_upload_size
id86620
size23,612
Frank Fischer (f-fr)

documentation

https://docs.rs/zopen

README

zopen

rs-graph crate zopen docs

Introduction

Simple crate that automatically open compressed files.

The compressor used is determined by the file extension. If the corresponding compression library is not available (i.e. the corresponding feature is not activated), the crate tries to use an external compression tool (gzip, bzip2, xz or zstd).

The crate exports two functions [read] and [write]. Given a file path, they return a Box<Read> or a Box<Write>, respectively, accessing the file. Depending on the file extension, the file is filtered through an appropriate compressor/decompressor.

Examples

Reading a compressed file:

let mut f = zopen::read("test.file.gz")?; // open gzip compressed file.
let mut data = String::new();
f.read_to_string(&mut data)?;

Writing to a compressed file:

let mut f = zopen::write("test.file.zst")?; // create zstd compressed file.
writeln!(f, "{}: {}", "Hello world", 42)?;

Author

Frank Fischer frank-fischer@shadow-soft.de

Installation

Put the requirement zopen = "^1.0.0" into the Cargo.toml of your project. Optionally, you may enable one (or all) of the features (gzip, bzip2, xz, zstd) to use external crates (instead of command line tools) for compression.

Documentation

See docs.rs.

Example

Reading a compressed file:

let mut f = zopen::read("test.file.gz")?; // open gzip compressed file.
let mut data = String::new();
f.read_to_string(&mut data)?;

Writing a compressed file:

let mut f = zopen::write("test.file.zst")?; // create zstd compressed file.
writeln!(f, "{}: {}", "Hello world", 42)?;

Download

Source code of latest tagged version: zopen-v1.0.0.tar.gz

Source code of trunk: zopen-trunk.tar.gz

Commit count: 0

cargo fmt