scoop:scoop.compression:0.1.0
src/asyncio/transfers.scoop
Selected production source · src/asyncio/transfers.scoop
1
package scoop.compression.asyncio3
import scoop.asyncio.*4
import scoop.compression.*6
/**7
* Copies a byte source through an encoder into the destination, finishes it, and returns actual8
* byte totals. The source and destination remain borrowed.9
*/10
public 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.totals15
}16
}18
/**19
* Copies and validates a complete compressed stream into the destination, returning actual byte20
* totals. The source and destination remain borrowed.21
*/22
public 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.totals27
}28
}