This is the low level workhorse method for the DEFLATE algorithms, but it's difficult to use and fragile with edge cases.  The compress_stream and compress_read are user-friendlier versions of the API taking case of most of the problems.  I left the low level API pub so that in case some people don't like the high level API and want to build their own.

Reader and Writer are not appropriate for a low level module like deflate.  decompress_stream_rw() is one such example.  See at the end how it discards the extra data.  It might be ok for some cases to discard data but it shouldn't be the universal case.  Providing the buffer-based API is absolutely essential.

The DEFLATE compressed data are usually embedded in another data stream.  It's rarely standalone.  E.g.  gzip file has its own down data, then embeds the deflated data, and ends with its own data again.  Same thing with zip file.  The buffer-based API let the caller have greater control in dealing with the data boundaries when transition between non-deflate data and deflate data.