ByteReadPacketPlatformBase

abstract class ByteReadPacketPlatformBase : ByteReadPacketBase

Constructors

Link copied to clipboard
fun ByteReadPacketPlatformBase(head: IoBuffer, remaining: Long, pool: ObjectPool<ChunkBuffer>)

Functions

Link copied to clipboard
fun canRead(): Boolean
Link copied to clipboard
override fun close()

Close input including the underlying source. All pending bytes will be discarded. It is not recommended to invoke it with read operations in-progress concurrently.

Link copied to clipboard
fun discard(n: Int): Int

Discards at most n bytes

override fun discard(n: Long): Long

Discard at most n bytes

Link copied to clipboard
fun discardExact(n: Int)

Discards exactly n bytes or fails with EOFException

Link copied to clipboard
fun ensureNextHead(current: ChunkBuffer): ChunkBuffer?
Link copied to clipboard
fun fixGapAfterRead(current: ChunkBuffer)
Link copied to clipboard
fun hasBytes(n: Int): Boolean
Link copied to clipboard
override fun peekTo(buffer: IoBuffer): Int

Copy available bytes to the specified buffer but keep them available. The underlying implementation could trigger bytes population from the underlying source and block until any bytes available.

override fun peekTo(destination: Memory, destinationOffset: Long, offset: Long, min: Long, max: Long): Long

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. min shouldn't be bigger than the destination free space. This function could trigger the underlying source reading that may lead to blocking I/O. It is allowed to specify too big offset so in this case this function will always return 0 after prefetching all underlying bytes but note that it may lead to significant memory consumption. This function usually copy more bytes than min (unless max = min) but it is not guaranteed. When 0 is returned with offset = 0 then it makes sense to check endOfInput.

Link copied to clipboard
fun prepareReadHead(minSize: Int): ChunkBuffer?
Link copied to clipboard
expect open fun readAvailable(dst: IoBuffer, length: Int): Int
expect open fun readAvailable(dst: ByteArray, offset: Int, length: Int): Int
expect open fun readAvailable(dst: DoubleArray, offset: Int, length: Int): Int
expect open fun readAvailable(dst: FloatArray, offset: Int, length: Int): Int
expect open fun readAvailable(dst: IntArray, offset: Int, length: Int): Int
expect open fun readAvailable(dst: LongArray, offset: Int, length: Int): Int
expect open fun readAvailable(dst: ShortArray, offset: Int, length: Int): Int
Link copied to clipboard
override fun readByte(): Byte

Read the next upcoming byte

Link copied to clipboard
override fun readDouble(): Double
Link copied to clipboard
override fun readFloat(): Float
Link copied to clipboard
expect open fun readFully(dst: IoBuffer, length: Int)
expect open fun readFully(dst: DoubleArray, offset: Int, length: Int)
expect open fun readFully(dst: FloatArray, offset: Int, length: Int)
expect open fun readFully(dst: IntArray, offset: Int, length: Int)
expect open fun readFully(dst: LongArray, offset: Int, length: Int)
expect open fun readFully(dst: ShortArray, offset: Int, length: Int)

override fun readFully(dst: ByteArray, offset: Int, length: Int)

Read exactly length bytes to dst array at specified offset

Link copied to clipboard
override fun readInt(): Int
Link copied to clipboard
override fun readLong(): Long
Link copied to clipboard
override fun readShort(): Short
Link copied to clipboard
fun readText(min: Int = 0, max: Int = Int.MAX_VALUE): String

Read a string at last min and at most max characters length

fun readText(out: Appendable, min: Int = 0, max: Int = Int.MAX_VALUE): Int

Read at least min and at most max characters and append them to out

Link copied to clipboard
fun readTextExact(exactCharacters: Int): String

Read a string exactly exactCharacters length

fun readTextExact(out: Appendable, exactCharacters: Int)

Read exactly exactCharacters characters and append them to out

Link copied to clipboard
fun release()

Release packet. After this function invocation the packet becomes empty. If it has been copied via ByteReadPacket.copy then the copy should be released as well.

Link copied to clipboard
override fun tryPeek(): Int

Returns next byte (unsigned) or -1 if no more bytes available

Link copied to clipboard
fun updateHeadRemaining(remaining: Int)

Properties

Link copied to clipboard
override var byteOrder: ByteOrder
Link copied to clipboard
override val endOfInput: Boolean

It is true when it is known that no more bytes will be available. When it is false then this means that it is not known yet or there are available bytes. Please note that false value doesn't guarantee that there are available bytes so readByte() may fail.

Link copied to clipboard
val isEmpty: Boolean

true if no bytes available for read

Link copied to clipboard
val isNotEmpty: Boolean
Link copied to clipboard
val pool: ObjectPool<ChunkBuffer>
Link copied to clipboard
val remaining: Long

Number of bytes available for read

Inheritors

Link copied to clipboard