expect interface ByteWriteChannel
Channel for asynchronous writing of sequences of bytes. This is a single-writer channel.
Operations on this channel cannot be invoked concurrently, unless explicitly specified otherwise in description. Exceptions are close and flush.
abstract val autoFlush: Boolean
Returns |
|
abstract val availableForWrite: Int
Returns number of bytes that can be written without suspension. Write operations do no suspend and return immediately when this number is at least the number of bytes requested for write. |
|
abstract val closedCause: Throwable?
An closure cause exception or |
|
abstract val isClosedForWrite: Boolean
Returns |
|
abstract val totalBytesWritten: Long
Number of bytes written to the channel. It is not guaranteed to be atomic so could be updated in the middle of write operation. |
|
abstract var
Byte order that is used for multi-byte write operations (such as writeShort, writeInt, writeLong, writeFloat, and writeDouble). |
abstract suspend fun awaitFreeSpace(): Unit
Invokes block when at least 1 byte is available for write. |
|
abstract fun close(cause: Throwable?): Boolean
Closes this channel with an optional exceptional cause.
It flushes all pending write bytes (via flush).
This is an idempotent operation -- repeated invocations of this function have no effect and return |
|
abstract fun flush(): Unit
Flushes all pending write bytes making them available for read. |
|
abstract suspend fun write(min: Int = 1, block: (ByteBuffer) -> Unit): Unit
Invokes block when it will be possible to write at least min bytes providing byte buffer to it so lambda can write to the buffer up to ByteBuffer.remaining bytes. If there are no min bytes spaces available then the invocation could suspend until the requirement will be met. |
|
abstract suspend fun writeAvailable(src: ByteArray, offset: Int, length: Int): Int
Writes as much as possible and only suspends if buffer is full abstract suspend fun writeAvailable(src: IoBuffer): Int abstract suspend fun writeAvailable(src: ByteBuffer): Int abstract fun writeAvailable(min: Int = 1, block: (ByteBuffer) -> Unit): Int
Invokes block if it is possible to write at least min byte providing byte buffer to it so lambda can write to the buffer up to ByteBuffer.remaining bytes. If there are no min bytes spaces available then the invocation returns 0. |
|
abstract suspend fun writeByte(b: Byte): Unit
Writes byte and suspends until written. Crashes if channel get closed while writing. |
|
abstract suspend fun writeDouble(d: Double): Unit
Writes double number and suspends until written. Crashes if channel get closed while writing. |
|
abstract suspend fun writeFloat(f: Float): Unit
Writes float number and suspends until written. Crashes if channel get closed while writing. |
|
abstract suspend fun writeFully(src: ByteArray, offset: Int, length: Int): Unit
Writes all src bytes and suspends until all bytes written. Causes flush if buffer filled up or when autoFlush Crashes if channel get closed while writing. abstract suspend fun writeFully(src: IoBuffer): Unit abstract suspend fun writeFully(src: Buffer): Unit abstract suspend fun writeFully(memory: Memory, startIndex: Int, endIndex: Int): Unit abstract suspend fun writeFully(src: ByteBuffer): Unit |
|
abstract suspend fun writeInt(i: Int): Unit
Writes int number and suspends until written. Crashes if channel get closed while writing. |
|
abstract suspend fun writeLong(l: Long): Unit
Writes long number and suspends until written. Crashes if channel get closed while writing. |
|
abstract suspend fun writePacket(packet: ByteReadPacket): Unit
Writes a packet fully or fails if channel get closed before the whole packet has been written |
|
abstract suspend fun writeShort(s: Short): Unit
Writes short number and suspends until written. Crashes if channel get closed while writing. |
|
abstract suspend fun |
|
abstract suspend fun writeWhile(block: (ByteBuffer) -> Boolean): Unit
Invokes block for every free buffer until it return |
fun ByteWriteChannel.close(): Boolean
Closes this channel with no failure (successfully) |
|
fun ByteWriteChannel.toOutputStream(parent: Job? = null): OutputStream
Create blocking java.io.OutputStream for this channel that does block every time the channel suspends at write Similar to do reading in runBlocking however you can pass it to regular blocking API |
|
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 |
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 |