BurntSushi / rust-snappy

Snappy compression implemented in Rust (including the Snappy frame format).
BSD 3-Clause "New" or "Revised" License
445 stars 43 forks source link

Implement `read::FrameEncoder` and rename existing APIs to match `flate2` #18

Closed emk closed 4 years ago

emk commented 6 years ago

Implements https://github.com/BurntSushi/rust-snappy/issues/17.

This patch reorganizes the API to work more like flate2 and adds a new snap::read::FrameEncoder which can be used to compress a Read object while reading from it. The new interfaces are:

As for tests:

I was able to refactor out the core of snap::write::FrameEncoder and re-use it, but the the two snap::read implementations do not yet share code, because it didn't seem to help the clarity very much.

emk commented 6 years ago

OK, this should be ready for code review! I feel like this is only at about 90% of my usual standard, because it took longer than I had planned and I'm feeling a bit out of it this morning. So please don't hesitate to suggest to improvements! I think it's probably still possible to share more code between snap::read::FrameDecoder and snap::write::FrameEncoder, but this morning I can't see any way to do it without adding a whole pile of potentially-clunky abstractions that feel a little forced. I was able to share the core of the framing code between write and read, so that's nice.

Thank you very much for considering this patch. And also for all your other awesome Rust stuff; we actually use several of your tools at Faraday and we're always delighted by the quality.

emk commented 4 years ago

Please do not feel guilty about how long it took! I also maintain many projects, though not nearly as many as you, and I understand completely.

Please make any changes that you think are appropriate. I fear that any insight I might have today, after a long week, is no special value.

Thank you once again for so many excellent crates! I've used so much of your Rust code over the years, and it's one of the things that I really enjoy about Rust.