interface ByteChannel : ByteReadChannel, ByteWriteChannel
Channel for asynchronous reading and writing of sequences of bytes. This is a buffered single-reader single-writer channel. |
|
abstract class ByteChannelSequentialBase : ByteChannel, ByteReadChannel, ByteWriteChannel, SuspendableReadSession, HasReadSession, HasWriteSession
Sequential (non-concurrent) byte channel implementation |
|
class ByteChannelSequentialJVM : ByteChannelSequentialBase |
|
expect interface ByteReadChannel
Channel for asynchronous reading of sequences of bytes. This is a single-reader channel. |
|
expect interface ByteWriteChannel
Channel for asynchronous writing of sequences of bytes. This is a single-writer channel. |
|
class ClosedWriteChannelException
Indicates attempt to write on isClosedForWrite channel that was closed without a cause. A failed channel rethrows the original close cause exception on send attempts. |
|
interface |
|
interface |
|
interface |
|
interface ReaderJob : Job
A coroutine job that is reading from a byte channel |
|
interface ReaderScope : CoroutineScope |
|
interface |
|
interface WriterJob : Job
A coroutine job that is writing to a byte channel |
|
interface WriterScope : CoroutineScope |
|
interface |
|
interface |
typealias CancellationException = <ERROR CLASS> |
|
typealias ConsumeEachBufferVisitor = (buffer: ByteBuffer, last: Boolean) -> Boolean
Visitor function that is invoked for every available buffer (or chunk) of a channel. The last parameter shows that the buffer is known to be the last. |
val
Byte channel that is always empty. |
expect fun ByteChannel(autoFlush: Boolean = false): ByteChannel
Creates buffered channel for asynchronous reading and writing of sequences of bytes. fun ByteChannel(autoFlush: Boolean = false, exceptionMapper: (Throwable?) -> Throwable?): ByteChannel
Creates buffered channel for asynchronous reading and writing of sequences of bytes using close function to close channel. |
|
fun ByteReadChannel(content: ByteArray): ByteReadChannel fun ByteReadChannel(content: ByteArray, offset: Int): ByteReadChannel
Creates channel for reading from the specified byte array. Please note that it could use content directly or copy it's bytes depending on the platform. expect fun ByteReadChannel(content: ByteArray, offset: Int, length: Int): ByteReadChannel
Creates channel for reading from the specified byte array. Please note that it could use content directly or copy it's bytes depending on the platform fun ByteReadChannel(text: String, charset: Charset = Charsets.UTF_8): ByteReadChannel fun ByteReadChannel(content: ByteBuffer): ByteReadChannel
Creates channel for reading from the specified byte buffer. |
|
fun ByteReadChannel.cancel(): Boolean |
|
fun ByteWriteChannel.close(): Boolean
Closes this channel with no failure (successfully) |
|
suspend fun ByteReadChannel.consumeEachBufferRange(visitor: ConsumeEachBufferVisitor): Unit
For every available bytes range invokes visitor function until it return false or end of stream encountered. The provided buffer should be never captured outside of the visitor block otherwise resource leaks, crashes and data corruptions may occur. The visitor block may be invoked multiple times, once or never. |
|
fun LookAheadSession.consumeEachRemaining(visitor: (ByteBuffer) -> Boolean): Unit suspend fun LookAheadSuspendSession.consumeEachRemaining(visitor: suspend (ByteBuffer) -> Boolean): Unit |
|
suspend fun ByteReadChannel.copyAndClose(dst: ByteWriteChannel, limit: Long = Long.MAX_VALUE): Long
Reads all the bytes from receiver channel and writes them to dst channel and then closes it. Closes dst channel if fails to read or write with cause exception. |
|
suspend fun ByteChannelSequentialBase. suspend fun ByteReadChannel.copyTo(dst: ByteWriteChannel): Long
Reads bytes from receiver channel and writes them to dst channel. Closes dst channel if fails to read or write with cause exception. suspend expect fun ByteReadChannel.copyTo(dst: ByteWriteChannel, limit: Long): Long
Reads up to limit bytes from receiver channel and writes them to dst channel. Closes dst channel if fails to read or write with cause exception. |
|
suspend fun ByteReadChannel.discard(): Long
Discards all bytes in the channel and suspends until end of stream. |
|
suspend fun ByteReadChannel.discardExact(n: Long): Unit
Discards exactly n bytes or fails if not enough bytes in the channel |
|
suspend fun ByteChannelSequentialBase. suspend expect fun ByteReadChannel.joinTo(dst: ByteWriteChannel, closeOnEnd: Boolean): Unit |
|
suspend fun ByteReadChannel.read(desiredSize: Int = 1, block: (source: Memory, start: Long, endExclusive: Long) -> Int): Int
Await until at least desiredSize is available for read or EOF and invoke block function. The block function should never capture a provided Memory instance outside otherwise an undefined behaviour may occur including accidental crash or data corruption. Block function should return number of bytes consumed or 0. |
|
suspend fun ByteReadChannel.readAvailable(dst: ByteArray): Int |
|
suspend fun ByteReadChannel.readDouble(byteOrder: ByteOrder): Double |
|
suspend fun ByteReadChannel.readDoubleLittleEndian(): Double |
|
suspend fun ByteReadChannel.readFloat(byteOrder: ByteOrder): Float |
|
suspend fun ByteReadChannel.readFloatLittleEndian(): Float |
|
suspend fun ByteReadChannel.readFully(dst: IoBuffer): Unit suspend fun ByteReadChannel.readFully(dst: ByteArray): Unit |
|
suspend fun ByteReadChannel.readInt(byteOrder: ByteOrder): Int |
|
suspend fun ByteReadChannel.readIntLittleEndian(): Int |
|
suspend fun ByteReadChannel.readLong(byteOrder: ByteOrder): Long |
|
suspend fun ByteReadChannel.readLongLittleEndian(): Long |
|
suspend fun ByteReadChannel.readPacket(size: Int): ByteReadPacket
Reads the specified amount of bytes and makes a byte packet from them. Fails if channel has been closed and not enough bytes available. |
|
suspend fun ByteReadChannel.readRemaining(limit: Long): ByteReadPacket
Reads up to limit bytes and makes a byte packet or until end of stream encountered. suspend fun ByteReadChannel.readRemaining(): ByteReadPacket
Reads all remaining bytes and makes a byte packet |
|
suspend fun ByteReadChannel.readShort(byteOrder: ByteOrder): Short |
|
suspend fun ByteReadChannel.readShortLittleEndian(): Short |
|
suspend fun ByteReadChannel.readUTF8Line(): String? |
|
suspend fun ByteReadChannel.readUTF8LineTo(out: Appendable): Boolean |
|
suspend fun ByteReadChannel.readUntilDelimiter(delimiter: ByteBuffer, dst: ByteBuffer): Int
Reads from the channel to the specified dst byte buffer until one of the following: |
|
fun fun |
|
suspend fun ByteReadChannel.skipDelimiter(delimiter: ByteBuffer): Unit |
|
fun <E : Throwable> tryCopyException(exception: E, cause: Throwable): E?
|
|
suspend fun ByteWriteChannel.write(desiredSpace: Int = 1, block: (freeSpace: Memory, startOffset: Long, endExclusive: Long) -> Int): Int
Await for desiredSpace will be available for write and invoke block function providing Memory instance and the corresponding range suitable for wiring in the memory. The block function should return number of bytes were written, possibly 0. |
|
suspend fun ByteWriteChannel.writeAvailable(src: ByteArray): Int |
|
suspend fun ByteWriteChannel.writeBoolean(b: Boolean): Unit |
|
suspend fun ByteWriteChannel.writeByte(b: Int): Unit |
|
suspend fun ByteWriteChannel.writeChar(ch: Char): Unit
Writes UTF16 character |
|
suspend fun ByteWriteChannel.writeDouble(value: Double, byteOrder: ByteOrder): Unit |
|
suspend fun ByteWriteChannel.writeDoubleLittleEndian(value: Double): Unit |
|
suspend fun ByteWriteChannel.writeFloat(value: Float, byteOrder: ByteOrder): Unit |
|
suspend fun ByteWriteChannel.writeFloatLittleEndian(value: Float): Unit |
|
suspend fun ByteWriteChannel.writeFully(src: ByteArray): Unit |
|
suspend fun ByteWriteChannel.writeInt(i: Long): Unit suspend fun ByteWriteChannel.writeInt(i: Long, byteOrder: ByteOrder): Unit suspend fun ByteWriteChannel.writeInt(value: Int, byteOrder: ByteOrder): Unit |
|
suspend fun ByteWriteChannel.writeIntLittleEndian(value: Int): Unit |
|
suspend fun ByteWriteChannel.writeLong(value: Long, byteOrder: ByteOrder): Unit |
|
suspend fun ByteWriteChannel.writeLongLittleEndian(value: Long): Unit |
|
suspend fun ByteWriteChannel.writePacket(headerSizeHint: Int = 0, builder: BytePacketBuilder.() -> Unit): Unit |
|
suspend fun ByteWriteChannel.writePacketSuspend(builder: suspend BytePacketBuilder.() -> Unit): Unit |
|
suspend fun ByteWriteChannel.writeShort(s: Int): Unit suspend fun ByteWriteChannel.writeShort(s: Int, byteOrder: ByteOrder): Unit suspend fun ByteWriteChannel.writeShort(value: Short, byteOrder: ByteOrder): Unit |
|
suspend fun ByteWriteChannel.writeShortLittleEndian(value: Short): Unit |
|
suspend fun ByteWriteChannel.writeStringUtf8(s: CharSequence): Unit suspend fun ByteWriteChannel.writeStringUtf8(s: String): Unit |
|
fun fun |