Skip to main content

Module io

Module io 

Source
Available on crate feature std only.
Expand description

std::io adapters over the streaming engines (feature std).

TypeReads or writesDoes
Readerreads from a compressed Readdecompresses
Writerwrites to a Writecompresses
Encoderreads from a plain Readcompresses
DecodeWriterwrites to a Writedecompresses

Each holds one 32 KiB buffer besides its engine. Decoders take Limits; errors come out as std::io::Error wrapping the crate’s Error.

use std::io::{Read, Write};

use compress_lib::{Format, Level, io};

let mut w = io::Writer::new(Vec::new(), Format::Gzip, Level::DEFAULT);
w.write_all(b"through std::io")?;
let packed = w.finish()?;

let mut r = io::Reader::new(&packed[..], Format::Gzip);
let mut text = String::new();
r.read_to_string(&mut text)?;
assert_eq!(text, "through std::io");

Structs§

DecodeWriter
Decompresses while writing: compressed data written in comes out plain in inner.
Encoder
Compresses while reading: reads plain data from inner and returns it compressed.
Reader
Decompresses while reading from a compressed source.
Writer
Compresses while writing to a destination.