asReadOnlyByteBuffer
Returns a new read-only heap ByteBuffer wrapping this ByteString's content.
Samples
import kotlinx.io.bytestring.*
import java.nio.ByteBuffer
import java.nio.ReadOnlyBufferException
import kotlin.test.*
fun main() {
//sampleStart
val str = "Hello World".encodeToByteString()
val buffer = str.asReadOnlyByteBuffer()
assertEquals(11, buffer.remaining())
assertEquals(0x48656c6c, buffer.getInt())
buffer.flip()
assertFailsWith<ReadOnlyBufferException> { buffer.put(42) }
//sampleEnd
}