pierrec / lz4

LZ4 compression and decompression in pure Go
BSD 3-Clause "New" or "Revised" License
878 stars 142 forks source link

Writer should be flushable #170

Closed dsnet closed 2 years ago

dsnet commented 2 years ago

There should be a Writer.Flush method that forces all buffered data to be compressed and flushed to the underlying writer.

This is useful when writing to network or disk where we need the guarantee that data is readable by the consumer up until flush is called.

The flate.Writer has a similar API:

Flush flushes any pending data to the underlying writer. It is useful mainly in compressed network protocols, to ensure that a remote reader has enough data to reconstruct a packet. Flush does not return until the data has been written. Calling Flush when there is no pending data still causes the Writer to emit a sync marker of at least 4 bytes. If the underlying writer returns an error, Flush returns that error.

dsnet commented 2 years ago

Thank you for being so quick to address this!