Lyricdev
GitHub

class DeflateWriter

pub class DeflateWriter<W :: [Writer]> :: [Writer, Closeable]

Conforms to Writer, Closeable.

A Writer that compresses the bytes given into raw DEFLATE blocks written to inner; close writes the final block. Level 0 stores, 1 uses the fixed tables over a greedy LZ77, 2 and up dynamic tables, 4 and up lazy matching.

Methods

pub static fn new(inner: W, level: int = 6): DeflateWriter<W> throws CompressError

Returns a writer at the level 0..9; 6 is the default, and -1 means 6.

Errors

Throws CompressError for a level outside -1 to 9.

pub fn bytesIn(): int

Returns the number of bytes taken so far.

pub fn bytesOut(): int

Returns the number of bytes written so far (the block under way not counted).

pub mut fn write(from: Slice<uint8>): int throws [IoError, Cancelled]
pub mut fn flush(): void throws [IoError, Cancelled]
pub fn close(): void throws [IoError, Cancelled]

Writes the final block and flushes the inner writer. A second close does nothing.

Errors

Throws IoError where writing to inner fails, and Cancelled where the task is cancelled during the write.