Skip to content

impl Drop #12

@goertzenator

Description

@goertzenator

The Encoders should have impl Drop that finishes the compressed stream upon drop(). BufWriter does something similar (flushes its buffer upon drop()).

My use case is Write trait objects. Consider the following trait object that writes compressed output to stdout...

fn make_writer_object() -> Box<Write> {
    let stdout = io::stdout();
    let buf_stdout = io::BufWriter::new(stdout);
    let gzip = gzip::Encoder::new(buf_stdout).unwrap();
    Box::new(gzip)
}

This doesn't work because the last bit of compressed data gets cut off.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions