Scoop API

scoop:scoop.compression:0.1.0

src/asyncio/transfers.scoop

Selected production source · src/asyncio/transfers.scoop

1package scoop.compression.asyncio
3import scoop.asyncio.*
4import scoop.compression.*
6/**
7 * Copies a byte source through an encoder into the destination, finishes it, and returns actual
8 * byte totals. The source and destination remain borrowed.
9 */
10public suspend fun AsyncByteSource.compressTo(destination: AsyncByteSink,
11 options: CompressionOptions = CompressionOptions.Zstd(ZstdOptions()), bufferSize: Long = 8192L): CompressionTotals {
12 return AsyncCompressionSource(this, options, bufferSize).useAsync suspend { source ->
13 source.copyTo(destination, bufferSize)
14 source.totals
15 }
18/**
19 * Copies and validates a complete compressed stream into the destination, returning actual byte
20 * totals. The source and destination remain borrowed.
21 */
22public suspend fun AsyncByteSource.decompressTo(destination: AsyncByteSink,
23 options: DecompressionOptions = DecompressionOptions(), bufferSize: Long = 8192L): CompressionTotals {
24 return AsyncDecompressionSource(this, options, bufferSize).useAsync suspend { source ->
25 source.copyTo(destination, bufferSize)
26 source.totals
27 }