Streaming Compressor
Stateful streaming compressor that processes data incrementally. Useful for compressing data that arrives in chunks (e.g., from network).
Usage:
val compressor = StreamingCompressor.create()
try {
while (hasMoreData) {
val chunk = receiveChunk()
compressor.compress(chunk) { compressedChunk ->
send(compressedChunk)
}
}
compressor.finish { finalChunk ->
send(finalChunk)
}
} finally {
compressor.close()
}Content copied to clipboard
Functions
Link copied to clipboard
Link copied to clipboard
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.