useSuspending

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

Suspending version of use for use with suspending I/O. Uses the efficient synchronous compressor but allows suspend calls in the block.

Usage with network I/O:

StreamingCompressor.create().useSuspending(onOutput = { channel.send(it) }) { compress ->
while (socket.hasData()) {
val chunk = socket.read() // suspend OK
compress(chunk)
}
}

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

Suspending version of use for use with suspending I/O.