RawSource
Supplies a stream of bytes. RawSource is a base interface for kotlinx-io
data suppliers.
The interface should be implemented to read data from wherever it's located: from the network, storage, or a buffer in memory. Sources may be layered to transform supplied data, such as to decompress, decrypt, or remove protocol framing.
Most applications shouldn't operate on a raw source directly, but rather on a buffered Source which is both more efficient and more convenient. Use buffered to wrap any raw source with a buffer.
Implementors should abstain from throwing exceptions other than those that are documented for RawSource methods.
Samples
kotlinx.io.samples.RC4DecryptingSourceimport kotlinx.io.*
import kotlin.test.Test
import kotlin.test.assertEquals
fun main() {
//sampleStart
val key = "key"
val source = Buffer().also { it.write(byteArrayOf(0x58, 0x09, 0x57, 0x9fU.toByte(), 0x41, 0xfbU.toByte())) }
val rc4Source = RC4DecryptingSource(source, key).buffered()
assertEquals("Secret", rc4Source.readString())
//sampleEnd
}