class ByteReadPacket : ByteReadPacketPlatformBase, Input
Read-only immutable byte packet. Could be consumed only once however it does support copy that doesn't copy every byte but creates a new view instead. Once packet created it should be either completely read (consumed) or released via release.
ByteReadPacket(head: ChunkBuffer, pool: ObjectPool<ChunkBuffer>) ByteReadPacket(head: IoBuffer, pool: ObjectPool<ChunkBuffer>) |
fun closeSource(): Unit
Should close the underlying bytes source. Could do nothing or throw exceptions. |
|
fun copy(): ByteReadPacket
Returns a copy of the packet. The original packet and the copy could be used concurrently. Both need to be either completely consumed or released via release |
|
fun fill(): ChunkBuffer?
Reads the next chunk suitable for reading or fun fill(destination: Memory, offset: Int, length: Int): Int
Read the next bytes into the destination starting at offset at most length bytes. May block until at least one byte is available. Usually bypass all exceptions from the underlying source. |
|
fun toString(): String |
val Empty: ByteReadPacket |
|
val ReservedSize: Int |
val ByteReadPacket.isEmpty: Boolean |
|
val ByteReadPacket.isNotEmpty: Boolean |
fun ByteReadPacket.$unsafeAppend$(builder: BytePacketBuilder): Unit |
|
fun Input. fun Input.completeReadHead(current: ChunkBuffer): Unit |
|
fun Input.copyTo(output: Output): Long
Copy all bytes to the output. Depending on actual input and output implementation it could be zero-copy or copy byte per byte. All regular types such as ByteReadPacket, BytePacketBuilder, AbstractInput and AbstractOutput are always optimized so no bytes will be copied. |
|
fun Input.discard(): Long
Discard all remaining bytes. |
|
fun Input.discardExact(n: Long): Unit fun Input.discardExact(n: Int): Unit
Discard exactly n bytes or fail if not enough bytes in the input to be discarded. |
|
fun Input.discardUntilDelimiter(delimiter: Byte): Long
Discards bytes until delimiter occurred |
|
fun Input.discardUntilDelimiters(delimiter1: Byte, delimiter2: Byte): Long
Discards bytes until of of the specified delimiters delimiter1 or delimiter2 occurred |
|
fun Input.forEach(block: (Byte) -> Unit): Unit
For every byte from this input invokes block function giving it as parameter. |
|
fun ByteReadPacket.inputStream(): InputStream
Creates InputStream adapter to the packet |
|
fun Input.peekCharUtf8(): Char |
|
fun Input. fun Input.
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 then
it simply return number of available bytes with no exception so the returned value need
to be checked.
It is safe to specify |
|
fun Input.prepareReadFirstHead(minSize: Int): ChunkBuffer? |
|
fun Input. |
|
fun Input.prepareReadNextHead(current: ChunkBuffer): ChunkBuffer? |
|
fun Input. |
|
fun ByteReadPacket.readAvailable(dst: ByteBuffer): Int
Read at most fun Input. fun Input.readAvailable(dst: ByteArray, offset: Int = 0, length: Int = dst.size - offset): Int fun Input.readAvailable(dst: ShortArray, offset: Int = 0, length: Int = dst.size - offset): Int fun Input.readAvailable(dst: IntArray, offset: Int = 0, length: Int = dst.size - offset): Int fun Input.readAvailable(dst: LongArray, offset: Int = 0, length: Int = dst.size - offset): Int fun Input.readAvailable(dst: FloatArray, offset: Int = 0, length: Int = dst.size - offset): Int fun Input.readAvailable(dst: DoubleArray, offset: Int = 0, length: Int = dst.size - offset): Int fun Input.readAvailable(dst: Buffer, length: Int = dst.writeRemaining): Int fun Input.readAvailable(destination: Memory, destinationOffset: Int, length: Int): Int fun Input.readAvailable(destination: Memory, destinationOffset: Long, length: Long): Long fun Input.readAvailable(dst: ByteBuffer, length: Int = dst.remaining()): Int |
|
fun Input.readAvailableLittleEndian(dst: <ERROR CLASS>, offset: Int = 0, length: Int = dst.size - offset): Int fun Input.readAvailableLittleEndian(dst: ShortArray, offset: Int = 0, length: Int = dst.size - offset): Int fun Input.readAvailableLittleEndian(dst: IntArray, offset: Int = 0, length: Int = dst.size - offset): Int fun Input.readAvailableLittleEndian(dst: LongArray, offset: Int = 0, length: Int = dst.size - offset): Int fun Input.readAvailableLittleEndian(dst: FloatArray, offset: Int = 0, length: Int = dst.size - offset): Int fun Input.readAvailableLittleEndian(dst: DoubleArray, offset: Int = 0, length: Int = dst.size - offset): Int |
|
fun Input. fun Input. fun Input. fun Input. fun Input. fun Input. |
|
fun ByteReadPacket.readByteBuffer(n: Int = remaining.coerceAtMostMaxIntOrFail("Unable to make a ByteBuffer: packet is too big"), direct: Boolean = false): ByteBuffer
Read exactly n (optional, read all remaining by default) bytes to a newly allocated byte buffer |
|
fun ByteReadPacket.readBytes(n: Int = remaining.coerceAtMostMaxIntOrFail("Unable to convert to a ByteArray: packet is too big")): ByteArray
Read exactly n bytes (consumes all remaining if n is not specified but up to Int.MAX_VALUE bytes). Does fail if not enough bytes remaining. fun Input.readBytes(): ByteArray
Reads all remaining bytes from the input |
|
fun Input.readBytesOf(min: Int = 0, max: Int = Int.MAX_VALUE): ByteArray
Reads at least min but no more than max bytes from the input to a new byte array |
|
fun ByteReadPacket.readDirect(size: Int, block: (ByteBuffer) -> Unit): Unit |
|
fun Input.readDouble(byteOrder: ByteOrder): Double fun Input.readDouble(): Double |
|
fun Input.readDoubleFallback(): Double |
|
fun Input.readDoubleLittleEndian(): Double |
|
fun Input.readFloat(byteOrder: ByteOrder): Float fun Input.readFloat(): Float |
|
fun Input.readFloatFallback(): Float |
|
fun Input.readFloatLittleEndian(): Float |
|
fun ByteReadPacket.readFully(dst: ByteBuffer): Int
Read exactly fun Input. fun Input.readFully(dst: ByteArray, offset: Int = 0, length: Int = dst.size - offset): Unit fun Input.readFully(dst: ShortArray, offset: Int = 0, length: Int = dst.size - offset): Unit fun Input.readFully(dst: IntArray, offset: Int = 0, length: Int = dst.size - offset): Unit fun Input.readFully(dst: LongArray, offset: Int = 0, length: Int = dst.size - offset): Unit fun Input.readFully(dst: FloatArray, offset: Int = 0, length: Int = dst.size - offset): Unit fun Input.readFully(dst: DoubleArray, offset: Int = 0, length: Int = dst.size - offset): Unit fun Input.readFully(dst: Buffer, length: Int = dst.writeRemaining): Unit fun Input.readFully(destination: Memory, destinationOffset: Int, length: Int): Unit fun Input.readFully(destination: Memory, destinationOffset: Long, length: Long): Unit fun Input.readFully(dst: <ERROR CLASS>, offset: Int = 0, length: Int = dst.size - offset): Unit fun Input.readFully(dst: ByteBuffer, length: Int = dst.remaining()): Unit |
|
fun Input.readFullyLittleEndian(dst: <ERROR CLASS>, offset: Int = 0, length: Int = dst.size - offset): Unit fun Input.readFullyLittleEndian(dst: ShortArray, offset: Int = 0, length: Int = dst.size - offset): Unit fun Input.readFullyLittleEndian(dst: IntArray, offset: Int = 0, length: Int = dst.size - offset): Unit fun Input.readFullyLittleEndian(dst: LongArray, offset: Int = 0, length: Int = dst.size - offset): Unit fun Input.readFullyLittleEndian(dst: FloatArray, offset: Int = 0, length: Int = dst.size - offset): Unit fun Input.readFullyLittleEndian(dst: DoubleArray, offset: Int = 0, length: Int = dst.size - offset): Unit |
|
fun Input. fun Input. fun Input. fun Input. fun Input. fun Input. |
|
fun Input.readInt(byteOrder: ByteOrder): Int fun Input.readInt(): Int |
|
fun Input.readIntLittleEndian(): Int |
|
fun Input.readLong(byteOrder: ByteOrder): Long fun Input.readLong(): Long |
|
fun Input.readLongLittleEndian(): Long |
|
fun Input.readShort(byteOrder: ByteOrder): Short fun Input.readShort(): Short |
|
fun Input.readShortLittleEndian(): Short |
|
fun ByteReadPacket. fun Input. fun Input.
Reads at most max characters decoding bytes with specified decoder. Extra character bytes will remain unconsumed fun Input.readText(out: Appendable, charset: Charset = Charsets.UTF_8, max: Int = Int.MAX_VALUE): Int fun Input.readText(charset: Charset = Charsets.UTF_8, max: Int = Int.MAX_VALUE): String
Reads at most max characters decoding bytes with specified charset. Extra character bytes will remain unconsumed |
|
fun Input.
Read exactly n characters interpreting bytes in the specified charset. |
|
fun Input.
Read exactly the specified number of bytes interpreting bytes in the specified charset (optional, UTF-8 by default). fun Input.readTextExactBytes(bytesCount: Int, charset: Charset = Charsets.UTF_8): String
Read exactly bytesCount interpreting bytes in the specified charset (optional, UTF-8 by default). |
|
fun Input.readTextExactCharacters(charactersCount: Int, charset: Charset = Charsets.UTF_8): String
Read exactly charactersCount characters interpreting bytes in the specified charset. |
|
fun Input.readUByte(): <ERROR CLASS> |
|
fun Input.readUInt(): <ERROR CLASS> |
|
fun Input.readULong(): <ERROR CLASS> |
|
fun Input.readUShort(): <ERROR CLASS> |
|
fun ByteReadPacket.readUTF8Line(estimate: Int = 16, limit: Int = Int.MAX_VALUE): String?
Read a string line considering optionally specified estimate but up to optional limit characters length
(does fail once limit exceeded) or return |
|
fun Input.readUTF8LineTo(out: Appendable, limit: Int): Boolean
Read UTF-8 line and append all line characters to out except line endings. Does support CR, LF and CR+LF |
|
fun Input.readUTF8UntilDelimiter(delimiters: String, limit: Int = Int.MAX_VALUE): String
Reads UTF-8 characters until one of the specified delimiters found, limit exceeded or end of stream encountered |
|
fun Input.readUTF8UntilDelimiterTo(out: Appendable, delimiters: String, limit: Int = Int.MAX_VALUE): Int fun Input.readUTF8UntilDelimiterTo(out: Output, delimiters: String, limit: Int = Int.MAX_VALUE): Int
Reads UTF-8 characters to out buffer until one of the specified delimiters found, limit exceeded or end of stream encountered fun Input. |
|
fun Input.readUntilDelimiter(delimiter: Byte, dst: ByteArray, offset: Int = 0, length: Int = dst.size): Int
Copies to dst array at offset at most length bytes or until the specified delimiter occurred. fun Input.readUntilDelimiter(delimiter: Byte, dst: Output): Long
Copies to dst output until the specified delimiter occurred. |
|
fun Input.readUntilDelimiters(delimiter1: Byte, delimiter2: Byte, dst: ByteArray, offset: Int = 0, length: Int = dst.size): Int
Copies to dst array at offset at most length bytes or until one of the specified delimiters delimiter1 or delimiter2 occurred. fun Input.readUntilDelimiters(delimiter1: Byte, delimiter2: Byte, dst: Output): Long
Copies to dst output until one of the specified delimiters delimiter1 or delimiter2 occurred. |
|
fun ByteReadPacket.readerUTF8(): Reader
Creates Reader from the byte packet that decodes UTF-8 characters |
|
fun Input.takeWhile(block: (Buffer) -> Boolean): Unit
Invoke block function for every chunk until end of input or block function return |
|
fun Input.takeWhileSize(initialSize: Int = 1, block: (Buffer) -> Int): Unit
Invoke block function for every chunk until end of input or block function return zero block function returns number of bytes required to read next primitive and shouldn't require too many bytes at once otherwise it could fail with an exception. It is not guaranteed that every chunk will have fixed size but it will be always at least requested bytes length. block function should never release provided buffer and should not write to it otherwise an undefined behaviour could be observed |