ktor-utils / io.ktor.util / kotlinx.coroutines.io.ByteReadChannel

Extensions for kotlinx.coroutines.io.ByteReadChannel

deflated

fun ByteReadChannel.deflated(gzip: Boolean = true, pool: ObjectPool<ByteBuffer> = KtorDefaultPool, coroutineContext: <ERROR CLASS> = Dispatchers.Unconfined): ByteReadChannel

Launch a coroutine on coroutineContext that does deflate compression optionally doing CRC and writing GZIP header and trailer if gzip = true

split

fun ByteReadChannel.split(coroutineScope: CoroutineScope): Pair<ByteReadChannel, ByteReadChannel>

Split source ByteReadChannel into 2 new one. Cancel of one channel in split(input or both outputs) cancels other channels.

toByteArray

suspend fun ByteReadChannel.toByteArray(): ByteArray

Read channel to byte array.