BurntSushi / rust-snappy

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

Resetting Encoder structs #49

Open Icelk opened 2 years ago

Icelk commented 2 years ago

The encoder structs create a new raw::Encoder each time you instantiate them. As stated by the docs, it's recommended to save the raw::Encoder. To prevent creating new raw::Encoders for each new encoding, could this crate provide a way to reset the higher level Read and Write encoders? Thanks!

BurntSushi commented 2 years ago

Feel free to propose an API.

Icelk commented 2 years ago

I suggest adding a into_inner method which returns the Encoder (private inside another struct EncoderInner) which you then can provide when calling with_inner. I can file a PR tomorrow.