use

inline fun <R> StreamingCompressor.use(noinline onOutput: (ReadBuffer) -> Unit, block: (compress: (ReadBuffer) -> Unit) -> R): R

Convenience function that handles compress, finish, and close automatically. All output chunks (from both compress and finish) go to the same callback.

Usage:

StreamingCompressor.create().use(onOutput = { send(it) }) { compress ->
compress(chunk1)
compress(chunk2)
// finish() and close() called automatically
}

inline fun <R> StreamingDecompressor.use(noinline onOutput: (ReadBuffer) -> Unit, block: (decompress: (ReadBuffer) -> Unit) -> R): R
inline suspend fun <R> SuspendingStreamingDecompressor.use(block: (decompress: suspend (ReadBuffer) -> List<ReadBuffer>) -> R): R

Convenience function that handles decompress, finish, and close automatically.


inline suspend fun <R> SuspendingStreamingCompressor.use(block: (compress: suspend (ReadBuffer) -> List<ReadBuffer>) -> R): R

Convenience function that handles compress, finish, and close automatically. Returns all output chunks (from both compress and finish calls).

Usage:

val allChunks = SuspendingStreamingCompressor.create().use { compress ->
compress(chunk1)
compress(chunk2)
// finish() and close() called automatically
}