Package io.ktor.utils.io
Types
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 : 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. |
|
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 |
Exceptions
class ClosedWriteChannelException : CancellationException 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. |
Type Aliases
typealias CancellationException = CancellationException |
|
typealias ConsumeEachBufferVisitor = (buffer: ByteBuffer, last: Boolean) -> Boolean |
Extensions for External Classes
Properties
val Byte channel that is always empty. |
Functions
expect fun ByteChannel( Creates buffered channel for asynchronous reading and writing of sequences of bytes. |
|
expect fun 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( 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( For every available bytes range invokes visitor function until it return false or end of stream encountered |
|
fun LookAheadSession.consumeEachRemaining( suspend fun LookAheadSuspendSession.consumeEachRemaining( |
|
suspend fun ByteReadChannel.copyAndClose( 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 expect fun ByteReadChannel.copyTo( 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( |
|
suspend fun ByteReadChannel.read( 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( |
|
suspend fun ByteReadChannel.readDouble( |
|
suspend fun ByteReadChannel.readDoubleLittleEndian(): Double |
|
suspend fun ByteReadChannel.readFloat( |
|
suspend fun ByteReadChannel.readFloatLittleEndian(): Float |
|
suspend fun ByteReadChannel.readFully(dst: IoBuffer): Unit suspend fun ByteReadChannel.readFully(dst: ByteArray): Unit |
|
suspend fun ByteReadChannel.readInt( |
|
suspend fun ByteReadChannel.readIntLittleEndian(): Int |
|
suspend fun ByteReadChannel.readLong( |
|
suspend fun ByteReadChannel.readLongLittleEndian(): Long |
|
suspend fun ByteReadChannel.readPacket( 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( 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( |
|
suspend fun ByteReadChannel.readShortLittleEndian(): Short |
|
suspend fun ByteReadChannel.readUTF8Line(): String? |
|
suspend fun ByteReadChannel.readUTF8LineTo( |
|
suspend fun ByteReadChannel.readUntilDelimiter( Reads from the channel to the specified dst byte buffer until one of the following: |
|
fun fun |
|
suspend fun ByteReadChannel.skipDelimiter( |
|
suspend fun ByteWriteChannel.write( 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( |
|
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( |
|
suspend fun ByteWriteChannel.writeDoubleLittleEndian( |
|
suspend fun ByteWriteChannel.writeFloat( |
|
suspend fun ByteWriteChannel.writeFloatLittleEndian( |
|
suspend fun ByteWriteChannel.writeFully(src: ByteArray): Unit |
|
suspend fun ByteWriteChannel.writeInt(i: Long): Unit suspend fun ByteWriteChannel.writeInt( suspend fun ByteWriteChannel.writeInt( |
|
suspend fun ByteWriteChannel.writeIntLittleEndian( |
|
suspend fun ByteWriteChannel.writeLong( |
|
suspend fun ByteWriteChannel.writeLongLittleEndian( |
|
suspend fun ByteWriteChannel.writePacket( |
|
suspend fun ByteWriteChannel.writePacketSuspend( |
|
suspend fun ByteWriteChannel.writeShort(s: Int): Unit suspend fun ByteWriteChannel.writeShort( suspend fun ByteWriteChannel.writeShort( |
|
suspend fun ByteWriteChannel.writeShortLittleEndian( |
|
suspend fun ByteWriteChannel.writeStringUtf8( suspend fun ByteWriteChannel.writeStringUtf8(s: String): Unit |
|
fun fun |