ByteWriteChannel

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.

actual 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.

actual 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.

actual 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.

Functions

Link copied to clipboard
expect abstract suspend fun awaitFreeSpace()

Invokes block when at least 1 byte is available for write.

actual abstract suspend fun awaitFreeSpace()
actual abstract suspend fun awaitFreeSpace()
actual abstract suspend fun awaitFreeSpace()
Link copied to clipboard
expect 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 false.

actual 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 false.

actual 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 false.

actual 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 false.

Link copied to clipboard
expect abstract fun flush()

Flushes all pending write bytes making them available for read.

actual abstract fun flush()

Flushes all pending write bytes making them available for read.

actual abstract fun flush()

Flushes all pending write bytes making them available for read.

actual abstract fun flush()

Flushes all pending write bytes making them available for read.

Link copied to clipboard
abstract suspend fun write(min: Int = 1, block: (ByteBuffer) -> 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.

Link copied to clipboard
expect abstract suspend fun writeAvailable(src: ChunkBuffer): Int
expect abstract suspend fun writeAvailable(src: ByteArray, offset: Int, length: Int): Int

Writes as much as possible and only suspends if buffer is full

actual abstract suspend fun writeAvailable(src: ChunkBuffer): Int
actual abstract suspend fun writeAvailable(src: ByteArray, offset: Int, length: Int): Int

Writes as much as possible and only suspends if buffer is full

actual abstract suspend fun writeAvailable(src: ChunkBuffer): 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.

actual abstract suspend fun writeAvailable(src: ByteArray, offset: Int, length: Int): Int

Writes as much as possible and only suspends if buffer is full

actual abstract suspend fun writeAvailable(src: ChunkBuffer): Int
actual abstract suspend fun writeAvailable(src: ByteArray, offset: Int, length: Int): Int
abstract suspend fun writeAvailable(src: CPointer<ByteVar>, offset: Int, length: Int): Int
abstract suspend fun writeAvailable(src: CPointer<ByteVar>, offset: Long, length: Long): Int

Writes as much as possible and only suspends if buffer is full

abstract fun writeAvailable(min: Int, block: (Buffer) -> Unit): Int

Invokes block if it is possible to write at least min byte providing buffer to it so lambda can write to the buffer up to Buffer.writeRemaining bytes. If there are no min bytes spaces available then the invocation returns -1.

Link copied to clipboard
expect abstract suspend fun writeByte(b: Byte)

Writes byte and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeByte(b: Byte)

Writes byte and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeByte(b: Byte)

Writes byte and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeByte(b: Byte)

Writes byte and suspends until written. Crashes if channel get closed while writing.

Link copied to clipboard
expect abstract suspend fun writeDouble(d: Double)

Writes double number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeDouble(d: Double)

Writes double number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeDouble(d: Double)

Writes double number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeDouble(d: Double)

Writes double number and suspends until written. Crashes if channel get closed while writing.

Link copied to clipboard
expect abstract suspend fun writeFloat(f: Float)

Writes float number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeFloat(f: Float)

Writes float number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeFloat(f: Float)

Writes float number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeFloat(f: Float)

Writes float number and suspends until written. Crashes if channel get closed while writing.

Link copied to clipboard
expect abstract suspend fun writeFully(src: Buffer)
expect abstract suspend fun writeFully(memory: Memory, startIndex: Int, endIndex: Int)

expect abstract suspend fun writeFully(src: ByteArray, offset: Int, length: Int)

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.

actual abstract suspend fun writeFully(src: Buffer)
actual abstract suspend fun writeFully(memory: Memory, startIndex: Int, endIndex: Int)

actual abstract suspend fun writeFully(src: ByteArray, offset: Int, length: Int)

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.

actual abstract suspend fun writeFully(src: Buffer)
abstract suspend fun writeFully(src: ByteBuffer)
actual abstract suspend fun writeFully(memory: Memory, startIndex: Int, endIndex: Int)

actual abstract suspend fun writeFully(src: ByteArray, offset: Int, length: Int)

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.

actual abstract suspend fun writeFully(src: Buffer)
actual abstract suspend fun writeFully(memory: Memory, startIndex: Int, endIndex: Int)

actual abstract suspend fun writeFully(src: ByteArray, offset: Int, length: Int)
abstract suspend fun writeFully(src: CPointer<ByteVar>, offset: Int, length: Int)
abstract suspend fun writeFully(src: CPointer<ByteVar>, offset: Long, length: Long)

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.

Link copied to clipboard
expect abstract suspend fun writeInt(i: Int)

Writes int number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeInt(i: Int)

Writes int number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeInt(i: Int)

Writes int number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeInt(i: Int)

Writes int number and suspends until written. Crashes if channel get closed while writing.

Link copied to clipboard
expect abstract suspend fun writeLong(l: Long)

Writes long number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeLong(l: Long)

Writes long number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeLong(l: Long)

Writes long number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeLong(l: Long)

Writes long number and suspends until written. Crashes if channel get closed while writing.

Link copied to clipboard
expect abstract suspend fun writePacket(packet: ByteReadPacket)

Writes a packet fully or fails if channel get closed before the whole packet has been written

actual abstract suspend fun writePacket(packet: ByteReadPacket)

Writes a packet fully or fails if channel get closed before the whole packet has been written

actual abstract suspend fun writePacket(packet: ByteReadPacket)

Writes a packet fully or fails if channel get closed before the whole packet has been written

actual abstract suspend fun writePacket(packet: ByteReadPacket)

Writes a packet fully or fails if channel get closed before the whole packet has been written

Link copied to clipboard
expect abstract suspend fun writeShort(s: Short)

Writes short number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeShort(s: Short)

Writes short number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeShort(s: Short)

Writes short number and suspends until written. Crashes if channel get closed while writing.

actual abstract suspend fun writeShort(s: Short)

Writes short number and suspends until written. Crashes if channel get closed while writing.

Link copied to clipboard
expect abstract suspend fun writeSuspendSession(visitor: suspend WriterSuspendSession.() -> Unit)
actual abstract suspend fun writeSuspendSession(visitor: suspend WriterSuspendSession.() -> Unit)
actual abstract suspend fun writeSuspendSession(visitor: suspend WriterSuspendSession.() -> Unit)
actual abstract suspend fun writeSuspendSession(visitor: suspend WriterSuspendSession.() -> Unit)
Link copied to clipboard
abstract suspend fun writeWhile(block: (ByteBuffer) -> Boolean)

Invokes block for every free buffer until it return false. It will also suspend every time when no free space available for write.

Properties

Link copied to clipboard
expect abstract val autoFlush: Boolean

Returns true if channel flushes automatically all pending bytes after every write function call. If false then flush only happens at manual flush invocation or when the buffer is full.

actual abstract val autoFlush: Boolean

Returns true if channel flushes automatically all pending bytes after every write function call. If false then flush only happens at manual flush invocation or when the buffer is full.

actual abstract val autoFlush: Boolean

Returns true if channel flushes automatically all pending bytes after every write function call. If false then flush only happens at manual flush invocation or when the buffer is full.

actual abstract val autoFlush: Boolean

Returns true if channel flushes automatically all pending bytes after every write function call. If false then flush only happens at manual flush invocation or when the buffer is full.

Link copied to clipboard
expect 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.

actual 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.

actual 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.

actual 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.

Link copied to clipboard
expect abstract val closedCause: Throwable?

A closure causes exception or null if closed successfully or not yet closed

actual abstract val closedCause: Throwable?

A closure causes exception or null if closed successfully or not yet closed

actual abstract val closedCause: Throwable?

A closure causes exception or null if closed successfully or not yet closed

actual abstract val closedCause: Throwable?

A closure causes exception or null if closed successfully or not yet closed

Link copied to clipboard
expect abstract val isClosedForWrite: Boolean

Returns true is channel has been closed and attempting to write to the channel will cause an exception.

actual abstract val isClosedForWrite: Boolean

Returns true is channel has been closed and attempting to write to the channel will cause an exception.

actual abstract val isClosedForWrite: Boolean

Returns true is channel has been closed and attempting to write to the channel will cause an exception.

actual abstract val isClosedForWrite: Boolean

Returns true is channel has been closed and attempting to write to the channel will cause an exception.

Link copied to clipboard
expect 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.

actual 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.

actual 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.

actual 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.

Inheritors

Link copied to clipboard
Link copied to clipboard

Extensions

Link copied to clipboard

Closes this channel with no failure (successfully)

Link copied to clipboard
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

Link copied to clipboard
inline 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.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Writes UTF16 character

Link copied to clipboard
suspend fun ByteWriteChannel.writeDouble(value: Double, byteOrder: ByteOrder)
Link copied to clipboard
Link copied to clipboard
suspend fun ByteWriteChannel.writeFloat(value: Float, byteOrder: ByteOrder)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
suspend fun ByteWriteChannel.writeInt(i: Long, byteOrder: ByteOrder)
suspend fun ByteWriteChannel.writeInt(value: Int, byteOrder: ByteOrder)
Link copied to clipboard
Link copied to clipboard
suspend fun ByteWriteChannel.writeLong(value: Long, byteOrder: ByteOrder)
Link copied to clipboard
Link copied to clipboard
inline suspend fun ByteWriteChannel.writePacket(builder: BytePacketBuilder.() -> Unit)
Link copied to clipboard
suspend fun ByteWriteChannel.writePacketSuspend(builder: suspend BytePacketBuilder.() -> Unit)
Link copied to clipboard
suspend fun ByteWriteChannel.writeShort(s: Int, byteOrder: ByteOrder)
suspend fun ByteWriteChannel.writeShort(value: Short, byteOrder: ByteOrder)
Link copied to clipboard
Link copied to clipboard