ByteChannelSequentialJVM
class ByteChannelSequentialJVM : ByteChannelSequentialBase
Constructors
Inherited Properties
open val autoFlush: Boolean Returns |
|
open val availableForRead: Int Returns number of bytes that can be read without suspension. Read operations do no suspend and return immediately when this number is at least the number of bytes requested for read. |
|
open 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. |
|
var closed: Boolean |
|
var closedCause: Throwable? An closure cause exception or |
|
open val isClosedForRead: Boolean Returns |
|
open val isClosedForWrite: Boolean Returns |
|
open var readByteOrder: ByteOrder Byte order that is used for multi-byte read operations (such as readShort, readInt, readLong, readFloat, and readDouble). |
|
val readable: ByteReadPacket |
|
open val totalBytesRead: Long Number of bytes read from the channel. It is not guaranteed to be atomic so could be updated in the middle of long running read operation. |
|
open 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. |
|
val writable: BytePacketBuilder |
|
open var writeByteOrder: ByteOrder Byte order that is used for multi-byte write operations (such as writeShort, writeInt, writeLong, writeFloat, and writeDouble). |
Functions
fun attachJob(job: Job): Unit |
|
suspend fun |
|
fun <R> lookAhead(visitor: LookAheadSession.() -> R): R |
|
suspend fun <R> lookAheadSuspend( |
|
suspend fun read( |
|
suspend fun readAvailable(dst: ByteBuffer): Int |
|
suspend fun readFully(dst: ByteBuffer): Int |
|
suspend fun write( |
|
suspend fun writeAvailable(src: ByteBuffer): Int |
|
suspend fun writeFully(src: ByteBuffer): Unit |
|
suspend fun writeWhile(block: (ByteBuffer) -> Boolean): Unit |
Inherited Functions
fun afterRead(): Unit |
|
fun afterWrite(): Unit |
|
Suspend until atLeast bytes become available or end of stream encountered (possibly due to exceptional close) |
|
suspend fun awaitFreeSpace(): Unit |
|
open fun beginWriteSession(): WriterSuspendSession |
|
Close channel with optional cause cancellation. Unlike ByteWriteChannel.close that could close channel normally, cancel does always close with error so any operations on this channel will always fail and all suspensions will be resumed with exception. |
|
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 |
|
Discard at most n available bytes or 0 if no bytes available yet Discard up to max bytes |
|
open fun endReadSession(): Unit |
|
open fun flush(): Unit Flushes all pending write bytes making them available for read. |
|
suspend fun peekTo( Try to copy at least min but up to max bytes to the specified destination buffer from this input
skipping offset bytes. If there are not enough bytes available to provide min bytes after skipping offset
bytes then it will trigger the underlying source reading first and after that will
simply copy available bytes even if EOF encountered so min is not a requirement but a desired number of bytes.
It is safe to specify max greater than the destination free space.
|
|
Reads all available bytes to dst buffer and returns immediately or suspends if no bytes available |
|
fun readAvailableClosed(): Int |
|
open suspend fun readBoolean(): Boolean Reads a boolean value (suspending if no bytes available yet) or fails if channel has been closed and not enough bytes. |
|
open suspend fun readByte(): Byte Reads a byte (suspending if no bytes available yet) or fails if channel has been closed and not enough bytes. |
|
open suspend fun readDouble(): Double Reads double number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes. |
|
open suspend fun readFloat(): Float Reads float number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes. |
|
Reads all length bytes to dst buffer or fails if channel has been closed. Suspends if not enough bytes available. |
|
open suspend fun readInt(): Int Reads an int number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes. |
|
open suspend fun readLong(): Long Reads a long number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes. |
|
open suspend fun 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. Accepts headerSizeHint to be provided, see WritePacket. |
|
open suspend fun readRemaining( Reads up to limit bytes and makes a byte packet or until end of stream encountered. Accepts headerSizeHint to be provided, see BytePacketBuilder. |
|
open fun Starts non-suspendable read session. After channel preparation consumer lambda will be invoked immediately event if there are no bytes available for read yet. |
|
open suspend fun readShort(): Short Reads a short number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes. |
|
open suspend fun Starts a suspendable read session. After channel preparation consumer lambda will be invoked immediately even if there are no bytes available for read yet. consumer lambda could suspend as much as needed. |
|
Reads a line of UTF-8 characters up to limit characters. Supports both CR-LF and LF line endings. Throws an exception if the specified limit has been exceeded. |
|
Reads a line of UTF-8 characters to the specified out buffer up to limit characters. Supports both CR-LF and LF line endings. Throws an exception if the specified limit has been exceeded. |
|
Request buffer range atLeast bytes length |
|
open fun startReadSession(): SuspendableReadSession |
|
Writes as much as possible and only suspends if buffer is full |
|
Writes byte and suspends until written. Crashes if channel get closed while writing. |
|
Writes double number and suspends until written. Crashes if channel get closed while writing. |
|
Writes float number and suspends until written. Crashes if channel get closed while writing. |
|
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. |
|
Writes int number and suspends until written. Crashes if channel get closed while writing. |
|
Writes long number and suspends until written. Crashes if channel get closed while writing. |
|
open suspend fun writePacket(packet: ByteReadPacket): Unit Writes a packet fully or fails if channel get closed before the whole packet has been written |
|
Writes short number and suspends until written. Crashes if channel get closed while writing. |
|
open suspend fun writeSuspendSession( |
Extension Functions
fun ByteWriteChannel.bufferedWriter( Open a buffered writer to the channel |
|
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 |
|
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 fun ByteReadChannel.copyTo( Copies up to limit bytes from this byte channel to out stream suspending on read channel and blocking on output |
|
suspend fun ByteReadChannel.copyTo( Copy up to limit bytes to blocking NIO channel. Copying to non-blocking channel requires selection and not supported. It does suspend if no data available in byte channel but may block if destination NIO channel blocks. suspend fun ByteReadChannel.copyTo( Copy up to limit bytes to blocking pipe. A shortcut to copyTo function with NIO channel destination |
|
fun ByteReadChannel.copyToBoth( Copy source channel to both output channels chunk by chunk. |
|
fun ByteReadChannel.deflated( fun ByteWriteChannel.deflated( Launch a coroutine on coroutineContext that does deflate compression
optionally doing CRC and writing GZIP header and trailer if gzip = |
|
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 fun ByteReadChannel.pass( Read data chunks from ByteReadChannel using buffer |
|
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: |
|
suspend fun ByteReadChannel.skipDelimiter( |
|
fun ByteReadChannel.split( Split source ByteReadChannel into 2 new one. Cancel of one channel in split(input or both outputs) cancels other channels. |
|
suspend fun ByteReadChannel.toByteArray(): ByteArray Read channel to byte array. |
|
suspend fun ByteReadChannel.toByteArray( Convert ByteReadChannel to ByteArray |
|
fun ByteReadChannel.toInputStream( Create blocking java.io.InputStream for this channel that does block every time the channel suspends at read Similar to do reading in runBlocking however you can pass it to regular blocking API |
|
fun ByteWriteChannel.toOutputStream( 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 |
|
fun ByteWriteChannel.use( Executes block on ByteWriteChannel and close it down correctly whether an exception |
|
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.write( |
|
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 ByteWriteChannel.writer( Open a writer to the channel |