scoop:scoop.compression:0.1.0
src/transfers.scoop
Selected production source · src/transfers.scoop
1
package scoop.compression3
import scoop.platform.io.ByteSource4
import scoop.platform.io.ByteSink5
import scoop.platform.io.copyTo7
/**8
* Copies a byte source through an encoder into the destination, finishes it, and returns actual9
* byte totals. The source and destination remain borrowed.10
*/11
public fun ByteSource.compressTo(destination: ByteSink, options: CompressionOptions = CompressionOptions.Zstd(ZstdOptions()),12
bufferSize: Long = 8192L): CompressionTotals = CompressionSource(this, options, bufferSize).use { source ->13
source.copyTo(destination, bufferSize)14
source.totals15
}17
/**18
* Copies and validates a complete compressed stream into the destination, returning actual byte19
* totals. The source and destination remain borrowed.20
*/21
public fun ByteSource.decompressTo(destination: ByteSink, options: DecompressionOptions = DecompressionOptions(),22
bufferSize: Long = 8192L): CompressionTotals = DecompressionSource(this, options, bufferSize).use { source ->23
source.copyTo(destination, bufferSize)24
source.totals25
}