Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finish ergonomics #4

Open
fpgaminer opened this issue Feb 9, 2016 · 3 comments
Open

finish ergonomics #4

fpgaminer opened this issue Feb 9, 2016 · 3 comments

Comments

@fpgaminer
Copy link
Owner

Right now, finish needs to be called on an LzmaWriter to get it to finish compressing/decompressing. This differs from the way a normal Write-like object works, so it's easy to forget and cause weird bugs.

Investigate the suggestion of using Drop to either call finish or panic if finish hasn't been called. BufWriter implements Drop like this: https://static.rust-lang.org/doc/master/src/std/io/buffered.rs.html#501-509

Credits to krdln for the feedback.

@mokasin
Copy link

mokasin commented Aug 18, 2017

I agree partly. Of course it is cumbersome to call finish and easily forgotten (maybe this should be stated more prominently in the documentation and README). But it has the drawback, that you never will get back the inner Write object. This makes writing multiple framed compressed objects to a Writer more difficult.

@mokasin
Copy link

mokasin commented Aug 18, 2017

Also the only way to react on errors in Drop is to panic. Which does not seem to be a good general approach.

@Pardoxa
Copy link

Pardoxa commented Jun 24, 2020

Maybe you could add a feature "finish_on_drop" or something like that.
That way each user can decide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants