egzreader

Crates.ioegzreader
lib.rsegzreader
version2.0.4
sourcesrc
created_at2021-04-18 11:26:16.141561
updated_at2022-01-16 17:27:58.073728
descriptionRead gzip/non-gzip stream easily.
homepage
repositoryhttps://github.com/akmizno/egzreader
max_upload_size
id386103
size23,767
(akmizno)

documentation

README

egzreader

Crates.io Documentation License

Read gzip/non-gzip stream easily in Rust.

Installation

# Cargo.toml
[dependencies]
egzreader = "2"

Example

use std::io::prelude::*;
use std::io;
use std::fs::File;
use egzreader::EgzReader;

fn read_hello() -> io::Result<()> {
    // text file
    let mut r1 = EgzReader::new(
        File::open("examples/hello.txt")?
    );
    // gzip encoded text file
    let mut r2 = EgzReader::new(
        File::open("examples/hello.txt.gz")?
    );

    let mut s1 = String::new();
    let mut s2 = String::new();

    r1.read_to_string(&mut s1)?;
    r2.read_to_string(&mut s2)?;

    assert_eq!(s1, "Hello!");
    assert_eq!(s2, "Hello!");

    Ok(())
}
Commit count: 33

cargo fmt