RawSink
Receives a stream of bytes. RawSink is a base interface for kotlinx-io
data receivers.
This interface should be implemented to write data wherever it's needed: to the network, storage, or a buffer in memory. Sinks may be layered to transform received data, such as to compress, encrypt, throttle, or add protocol framing.
Most application code shouldn't operate on a raw sink directly, but rather on a buffered Sink which is both more efficient and more convenient. Use buffered to wrap any raw sink with a buffer.
Implementors should abstain from throwing exceptions other than those that are documented for RawSink methods.
Samples
kotlinx.io.samples.CRC32Sinkimport kotlinx.io.*
import kotlin.test.Test
import kotlin.test.assertEquals
fun main() {
//sampleStart
val crc32Sink = CRC32Sink(discardingSink())
crc32Sink.buffered().use {
it.writeString("hello crc32")
}
assertEquals(0x9896d398U, crc32Sink.crc32())
//sampleEnd
}