Package io.ktor.utils.io.core

Types

AbstractInput
Link copied to clipboard
common
abstract class AbstractInput(head: ChunkBuffer, remaining: Long, pool: ObjectPool<ChunkBuffer>) : Input
The default abstract base class implementing Input interface.
AbstractOutput
Link copied to clipboard
common
abstract class AbstractOutput : Appendable, Output
The default Output implementation.
Buffer
Link copied to clipboard
common
open class Buffer(memory: Memory)
Represents a buffer with read and write positions.
BufferLimitExceededException
Link copied to clipboard
common
class BufferLimitExceededException(message: String) : Exception
ByteOrder
Link copied to clipboard
common
enum ByteOrder : Enum<ByteOrder>
BytePacketBuilder
Link copied to clipboard
common
class BytePacketBuilder(headerSizeHint: Int, pool: ObjectPool<ChunkBuffer>) : BytePacketBuilderPlatformBase
A builder that provides ability to build byte packets with no knowledge of it's size.
BytePacketBuilderBase
Link copied to clipboard
common
abstract class BytePacketBuilderBase : AbstractOutput
BytePacketBuilderPlatformBase
Link copied to clipboard
common
abstract class BytePacketBuilderPlatformBase : BytePacketBuilderBase
ByteReadPacket
Link copied to clipboard
common
class ByteReadPacket : ByteReadPacketPlatformBase, Input
Read-only immutable byte packet.
ByteReadPacketBase
Link copied to clipboard
common
abstract class ByteReadPacketBase(head: ChunkBuffer, remaining: Long, pool: ObjectPool<ChunkBuffer>) : AbstractInput
ByteReadPacketPlatformBase
Link copied to clipboard
common
abstract class ByteReadPacketPlatformBase : ByteReadPacketBase
Closeable
Link copied to clipboard
interface Closeable
typealias Closeable = Closeable
EOFException
Link copied to clipboard
class EOFException(message: String) : IOException
typealias EOFException = EOFException
typealias EOFException = EOFException
ExperimentalIoApi
Link copied to clipboard
common
annotation class ExperimentalIoApi
API marked with this annotation is experimental and could be changed
Input
Link copied to clipboard
common
interface Input : Closeable
Usually shouldn't be implemented directly.
interface Input : Closeable
Shouldn't be implemented directly.
posix
interface Input : Closeable
InsufficientSpaceException
Link copied to clipboard
common
class InsufficientSpaceException(message: String) : Exception
IoBuffer
Link copied to clipboard
common
class IoBuffer : ChunkBuffer, Input, Output
A read-write facade to actual buffer of fixed size.
class IoBuffer : ChunkBuffer, Input, Output
A read-write facade to actual buffer of fixed size.
posix
class IoBuffer : ChunkBuffer, Input, Output
Output
Link copied to clipboard
common
interface Output : Appendable, Closeable
This shouldn't be implemented directly.
interface Output : Closeable, Appendable
This shouldn't be implemented directly.
posix
interface Output : Closeable

Functions

append
Link copied to clipboard
common
fun Buffer.append(c: Char): Buffer
fun Buffer.append(csq: CharSequence?): Buffer
fun Buffer.append(csq: CharArray, start: Int, end: Int): Buffer
fun Buffer.append(csq: CharSequence?, start: Int, end: Int): Buffer
fun Output.append(csq: CharArray, start: Int = 0, end: Int = csq.size): Appendable
fun Output.append(csq: CharSequence, start: Int = 0, end: Int = csq.length): Appendable
buildPacket
Link copied to clipboard
common
inline fun buildPacket(headerSizeHint: Int = 0, block: BytePacketBuilder.() -> Unit): ByteReadPacket
Build a byte packet in block lambda.
BytePacketBuilder
Link copied to clipboard
fun BytePacketBuilder(headerSizeHint: Int = 0): BytePacketBuilder
fun BytePacketBuilder(headerSizeHint: Int = 0): BytePacketBuilder
fun BytePacketBuilder(headerSizeHint: Int = 0): BytePacketBuilder
ByteReadPacket
Link copied to clipboard
fun ByteReadPacket(bb: ByteBuffer, release: (ByteBuffer) -> Unit = {}): ByteReadPacket
inline fun ByteReadPacket(array: ByteArray, offset: Int = 0, length: Int = array.size, crossinline block: (ByteArray) -> Unit): ByteReadPacket
inline fun ByteReadPacket(array: ByteArray, offset: Int = 0, length: Int = array.size): ByteReadPacket
fun ByteReadPacket(array: ByteArray, offset: Int = 0, length: Int = array.size, block: (ByteArray) -> Unit): ByteReadPacket
fun ByteReadPacket(array: ByteArray, offset: Int = 0, length: Int = array.size, block: (ByteArray) -> Unit): ByteReadPacket
canRead
Link copied to clipboard
common
inline fun Buffer.canRead(): Boolean
canWrite
Link copied to clipboard
common
inline fun Buffer.canWrite(): Boolean
ChunkBuffer
Link copied to clipboard
posix
fun ChunkBuffer(ptr: <ERROR CLASS><out <ERROR CLASS>>, lengthInBytes: Int, origin: ChunkBuffer?): ChunkBuffer
fun ChunkBuffer(ptr: <ERROR CLASS><out <ERROR CLASS>>, lengthInBytes: Long, origin: ChunkBuffer?): ChunkBuffer
copyTo
Link copied to clipboard
common
fun Input.copyTo(output: Output): Long
Copy all bytes to the output.
discard
Link copied to clipboard
common
fun Input.discard(): Long
Discard all remaining bytes.
discardExact
Link copied to clipboard
common
fun Input.discardExact(n: Int)
Discard exactly n bytes or fail if not enough bytes in the input to be discarded.
fun Input.discardExact(n: Long)
Discard exactly n bytes or fail if not enough bytes in the input to be discarded.
discardUntilDelimiter
Link copied to clipboard
common
fun Input.discardUntilDelimiter(delimiter: Byte): Long
Discards bytes until delimiter occurred
discardUntilDelimiters
Link copied to clipboard
common
fun Input.discardUntilDelimiters(delimiter1: Byte, delimiter2: Byte): Long
Discards bytes until of of the specified delimiters delimiter1 or delimiter2 occurred
fill
Link copied to clipboard
common
fun Buffer.fill(times: Int, value: Byte)
Write byte value repeated the specified times.
fun Buffer.fill(times: Int, value: UByte)
Write unsigned byte value repeated the specified times.
fun Buffer.fill(n: Long, v: Byte)
Write byte v value repeated n times.
fun Output.fill(times: Long, value: Byte = 0)
flush
Link copied to clipboard
common
fun Buffer.flush()
forEach
Link copied to clipboard
common
inline fun Buffer.forEach(block: (Byte) -> Unit)
For every byte from this buffer invokes block function giving it as parameter.
inline fun Input.forEach(block: (Byte) -> Unit)
For every byte from this input invokes block function giving it as parameter.
makeView
Link copied to clipboard
common
fun Buffer.makeView(): Buffer
fun ChunkBuffer.makeView(): ChunkBuffer
peekCharUtf8
Link copied to clipboard
common
fun Input.peekCharUtf8(): Char
peekTo
Link copied to clipboard
common
fun Input.peekTo(destination: Buffer, offset: Int = 0, min: Int = 1, max: Int = Int.MAX_VALUE): Int
Copy at least min but up to max bytes to the specified destination buffer from this input skipping offset bytes.
fun Input.peekTo(destination: IoBuffer, offset: Int = 0, min: Int = 1, max: Int = Int.MAX_VALUE): Int
Copy at least min but up to max bytes to the specified destination buffer from this input skipping offset bytes.
preview
Link copied to clipboard
common
inline fun <R> BytePacketBuilder.preview(block: (tmp: ByteReadPacket) -> R): R
Creates a temporary packet view of the packet being build without discarding any bytes from the builder.
pushBack
Link copied to clipboard
common
fun Buffer.pushBack(n: Int)
Push back n bytes: only possible if there were at least n bytes read before this operation.
read
Link copied to clipboard
common
inline fun Buffer.read(block: (memory: Memory, start: Int, endExclusive: Int) -> Int): Int
Apply block of code with buffer's memory providing read range indices.
readAvailable
Link copied to clipboard
fun ByteReadPacket.readAvailable(dst: ByteBuffer): Int
Read at most dst.remaining() bytes to the specified dst byte buffer and change it's position accordingly
common
fun Buffer.readAvailable(dst: Buffer, length: Int = dst.writeRemaining): Int
Read at most length available bytes to the dst buffer or -1 if no bytes available for read.
fun Buffer.readAvailable(dst: ByteBuffer, length: Int = dst.remaining()): Int
fun Input.readAvailable(dst: ByteBuffer, length: Int = dst.remaining()): Int
fun Input.readAvailable(dst: Buffer, length: Int = dst.writeRemaining): Int
fun Input.readAvailable(dst: IoBuffer, size: 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: ByteArray, 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: FloatArray, 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: ShortArray, offset: Int = 0, length: Int = dst.size - offset): Int
inline fun IoBuffer.readAvailable(destination: ByteArray, offset: Int = 0, length: Int = destination.size - offset): Int
fun Buffer.readAvailable(pointer: <ERROR CLASS><<ERROR CLASS>>, offset: Int, length: Int): Int
fun Buffer.readAvailable(pointer: <ERROR CLASS><<ERROR CLASS>>, offset: Long, length: Int): Int
fun Input.readAvailable(dst: <ERROR CLASS><<ERROR CLASS>>, offset: Int, length: Int): Int
fun Input.readAvailable(dst: <ERROR CLASS><<ERROR CLASS>>, offset: Long, length: Long): Long
posix
fun ByteReadPacket.readAvailable(dst: <ERROR CLASS><<ERROR CLASS>>, limit: Int): Int
Read at most limit bytes to the specified dst address
posix
fun ByteReadPacket.readAvailable(dst: <ERROR CLASS><<ERROR CLASS>>, limit: Long): Long
Read at most limit bytes to the specified dst address
common
fun Buffer.readAvailable(destination: ByteArray, offset: Int = 0, length: Int = destination.size - offset): Int
Read available for read bytes to the destination array range starting at array offset and length bytes.
common
fun Buffer.readAvailable(destination: DoubleArray, offset: Int = 0, length: Int = destination.size - offset): Int
Read available for read bytes to the destination array range starting at array offset and length elements.
common
fun Buffer.readAvailable(destination: FloatArray, offset: Int = 0, length: Int = destination.size - offset): Int
Read available for read bytes to the destination array range starting at array offset and length elements.
common
fun Buffer.readAvailable(destination: IntArray, offset: Int = 0, length: Int = destination.size - offset): Int
Read available for read bytes to the destination array range starting at array offset and length elements.
common
fun Buffer.readAvailable(destination: LongArray, offset: Int = 0, length: Int = destination.size - offset): Int
Read available for read bytes to the destination array range starting at array offset and length elements.
common
fun Buffer.readAvailable(destination: ShortArray, offset: Int = 0, length: Int = destination.size - offset): Int
Read available for read bytes to the destination array range starting at array offset and length elements.
common
fun Buffer.readAvailable(destination: UByteArray, offset: Int = 0, length: Int = destination.size - offset): Int
Read available for read bytes to the destination array range starting at array offset and length bytes.
common
fun Buffer.readAvailable(destination: UIntArray, offset: Int = 0, length: Int = destination.size - offset): Int
Read available for read bytes to the destination array range starting at array offset and length elements.
common
fun Buffer.readAvailable(destination: ULongArray, offset: Int = 0, length: Int = destination.size - offset): Int
Read available for read bytes to the destination array range starting at array offset and length elements.
common
fun Buffer.readAvailable(destination: UShortArray, offset: Int = 0, length: Int = destination.size - offset): Int
Read available for read bytes to the destination array range starting at array offset and length elements.
readAvailableLittleEndian
Link copied to clipboard
common
fun Buffer.readAvailableLittleEndian(dst: DoubleArray, offset: Int = 0, length: Int = dst.size - offset): Int
fun Buffer.readAvailableLittleEndian(dst: FloatArray, offset: Int = 0, length: Int = dst.size - offset): Int
fun Buffer.readAvailableLittleEndian(dst: IntArray, offset: Int = 0, length: Int = dst.size - offset): Int
fun Buffer.readAvailableLittleEndian(dst: LongArray, offset: Int = 0, length: Int = dst.size - offset): Int
fun Buffer.readAvailableLittleEndian(dst: ShortArray, offset: Int = 0, length: Int = dst.size - offset): Int
fun Buffer.readAvailableLittleEndian(dst: UIntArray, offset: Int = 0, length: Int = dst.size - offset): Int
fun Buffer.readAvailableLittleEndian(dst: ULongArray, offset: Int = 0, length: Int = dst.size - offset): Int
fun Buffer.readAvailableLittleEndian(dst: UShortArray, 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.readAvailableLittleEndian(dst: FloatArray, 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: ShortArray, offset: Int = 0, length: Int = dst.size - offset): Int
fun Input.readAvailableLittleEndian(dst: UIntArray, offset: Int = 0, length: Int = dst.size - offset): Int
fun Input.readAvailableLittleEndian(dst: ULongArray, offset: Int = 0, length: Int = dst.size - offset): Int
fun Input.readAvailableLittleEndian(dst: UShortArray, offset: Int = 0, length: Int = dst.size - offset): Int
readAvailableOld
Link copied to clipboard
common
@JvmName(name = readAvailable)
fun Input.readAvailableOld(dst: ByteArray, offset: Int = 0, length: Int = dst.size - offset): Int
@JvmName(name = readAvailable)
fun Input.readAvailableOld(dst: DoubleArray, offset: Int = 0, length: Int = dst.size - offset): Int
@JvmName(name = readAvailable)
fun Input.readAvailableOld(dst: FloatArray, offset: Int = 0, length: Int = dst.size - offset): Int
@JvmName(name = readAvailable)
fun Input.readAvailableOld(dst: IntArray, offset: Int = 0, length: Int = dst.size - offset): Int
@JvmName(name = readAvailable)
fun Input.readAvailableOld(dst: LongArray, offset: Int = 0, length: Int = dst.size - offset): Int
@JvmName(name = readAvailable)
fun Input.readAvailableOld(dst: ShortArray, offset: Int = 0, length: Int = dst.size - offset): Int
readByteBuffer
Link copied to clipboard
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
readBytes
Link copied to clipboard
common
fun Input.readBytes(): ByteArray
Reads all remaining bytes from the input
fun Buffer.readBytes(count: Int = readRemaining): ByteArray
Read the specified number of bytes specified (optional, read all remaining by default)
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).
fun Input.readBytes(n: Int): ByteArray
Reads exactly n bytes from the input or fails if not enough bytes available.
readBytesOf
Link copied to clipboard
common
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
readDirect
Link copied to clipboard
inline fun Buffer.readDirect(block: (<ERROR CLASS><<ERROR CLASS>>) -> Int): Int
inline fun Buffer.readDirect(block: (ByteBuffer) -> Unit): Int
inline fun AbstractInput.readDirect(size: Int, block: (ByteBuffer) -> Unit)
inline fun ByteReadPacket.readDirect(size: Int, block: (ByteBuffer) -> Unit)
inline fun ByteReadPacketBase.readDirect(size: Int, block: (ByteBuffer) -> Unit)
readDouble
Link copied to clipboard
common
fun Buffer.readDouble(): Double
Read a floating point number or fail if not enough bytes available for reading.
fun Input.readDouble(): Double
inline fun IoBuffer.readDouble(): Double
fun Input.readDouble(byteOrder: ByteOrder): Double
readDoubleFallback
Link copied to clipboard
common
fun Input.readDoubleFallback(): Double
readDoubleLittleEndian
Link copied to clipboard
common
fun Buffer.readDoubleLittleEndian(): Double
fun Input.readDoubleLittleEndian(): Double
readFloat
Link copied to clipboard
common
fun Buffer.readFloat(): Float
Read a floating point number or fail if not enough bytes available for reading.
fun Input.readFloat(): Float
inline fun IoBuffer.readFloat(): Float
fun Input.readFloat(byteOrder: ByteOrder): Float
readFloatFallback
Link copied to clipboard
common
fun Input.readFloatFallback(): Float
readFloatLittleEndian
Link copied to clipboard
common
fun Buffer.readFloatLittleEndian(): Float
fun Input.readFloatLittleEndian(): Float
readFully
Link copied to clipboard
fun Buffer.readFully(destination: ByteBuffer)
Read buffer's content to the destination buffer moving it's position.
fun ByteReadPacket.readFully(dst: ByteBuffer): Int
Read exactly dst.remaining() bytes to the specified dst byte buffer and change it's position accordingly
common
fun Buffer.readFully(dst: Buffer, length: Int = dst.writeRemaining): Int
Read at most length bytes from this buffer to the dst buffer.
fun Buffer.readFully(dst: ByteBuffer, length: Int)
fun Input.readFully(dst: ByteBuffer, length: Int = dst.remaining())
fun Input.readFully(dst: Buffer, length: Int = dst.writeRemaining)
fun Input.readFully(dst: IoBuffer, size: Int = dst.writeRemaining)
fun Buffer.readFully(dst: Array<Byte>, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFully(destination: Memory, destinationOffset: Int, length: Int)
fun Input.readFully(destination: Memory, destinationOffset: Long, length: Long)
fun Input.readFully(dst: ByteArray, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFully(dst: DoubleArray, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFully(dst: FloatArray, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFully(dst: IntArray, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFully(dst: LongArray, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFully(dst: ShortArray, offset: Int = 0, length: Int = dst.size - offset)
inline fun Input.readFully(dst: UByteArray, offset: Int = 0, length: Int = dst.size - offset)
inline fun Input.readFully(dst: UIntArray, offset: Int = 0, length: Int = dst.size - offset)
inline fun Input.readFully(dst: ULongArray, offset: Int = 0, length: Int = dst.size - offset)
inline fun Input.readFully(dst: UShortArray, offset: Int = 0, length: Int = dst.size - offset)
inline fun IoBuffer.readFully(destination: ByteArray, offset: Int = 0, length: Int = destination.size - offset)
fun Buffer.readFully(pointer: <ERROR CLASS><<ERROR CLASS>>, offset: Int, length: Int)
fun Buffer.readFully(pointer: <ERROR CLASS><<ERROR CLASS>>, offset: Long, length: Int)
fun Input.readFully(dst: <ERROR CLASS><<ERROR CLASS>>, offset: Int, length: Int)
fun Input.readFully(dst: <ERROR CLASS><<ERROR CLASS>>, offset: Long, length: Long)
posix
fun ByteReadPacket.readFully(dst: <ERROR CLASS><<ERROR CLASS>>, size: Int): Int
Read exactly size bytes to the specified dst address
posix
fun ByteReadPacket.readFully(dst: <ERROR CLASS><<ERROR CLASS>>, size: Long): Long
Read exactly size bytes to the specified dst address
common
fun Buffer.readFully(destination: ByteArray, offset: Int = 0, length: Int = destination.size - offset)
Read from this buffer to the destination array to offset and length bytes.
common
fun Buffer.readFully(destination: DoubleArray, offset: Int = 0, length: Int = destination.size - offset)
Read from this buffer to the destination array to offset and length bytes.
common
fun Buffer.readFully(destination: FloatArray, offset: Int = 0, length: Int = destination.size - offset)
Read from this buffer to the destination array to offset and length bytes.
common
fun Buffer.readFully(destination: IntArray, offset: Int = 0, length: Int = destination.size - offset)
Read from this buffer to the destination array to offset and length bytes.
common
fun Buffer.readFully(destination: LongArray, offset: Int = 0, length: Int = destination.size - offset)
Read from this buffer to the destination array to offset and length bytes.
common
fun Buffer.readFully(destination: ShortArray, offset: Int = 0, length: Int = destination.size - offset)
Read from this buffer to the destination array to offset and length bytes.
common
fun Buffer.readFully(destination: UByteArray, offset: Int = 0, length: Int = destination.size - offset)
Read from this buffer to the destination array to offset and length bytes.
common
fun Buffer.readFully(destination: UIntArray, offset: Int = 0, length: Int = destination.size - offset)
Read from this buffer to the destination array to offset and length bytes.
common
fun Buffer.readFully(destination: ULongArray, offset: Int = 0, length: Int = destination.size - offset)
Read from this buffer to the destination array to offset and length bytes.
common
fun Buffer.readFully(destination: UShortArray, offset: Int = 0, length: Int = destination.size - offset)
Read from this buffer to the destination array to offset and length bytes.
readFullyLittleEndian
Link copied to clipboard
common
fun Buffer.readFullyLittleEndian(dst: DoubleArray, offset: Int = 0, length: Int = dst.size - offset)
fun Buffer.readFullyLittleEndian(dst: FloatArray, offset: Int = 0, length: Int = dst.size - offset)
fun Buffer.readFullyLittleEndian(dst: IntArray, offset: Int = 0, length: Int = dst.size - offset)
fun Buffer.readFullyLittleEndian(dst: LongArray, offset: Int = 0, length: Int = dst.size - offset)
fun Buffer.readFullyLittleEndian(dst: ShortArray, offset: Int = 0, length: Int = dst.size - offset)
fun Buffer.readFullyLittleEndian(dst: UIntArray, offset: Int = 0, length: Int = dst.size - offset)
fun Buffer.readFullyLittleEndian(dst: ULongArray, offset: Int = 0, length: Int = dst.size - offset)
fun Buffer.readFullyLittleEndian(dst: UShortArray, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFullyLittleEndian(dst: DoubleArray, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFullyLittleEndian(dst: FloatArray, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFullyLittleEndian(dst: IntArray, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFullyLittleEndian(dst: LongArray, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFullyLittleEndian(dst: ShortArray, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFullyLittleEndian(dst: UIntArray, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFullyLittleEndian(dst: ULongArray, offset: Int = 0, length: Int = dst.size - offset)
fun Input.readFullyLittleEndian(dst: UShortArray, offset: Int = 0, length: Int = dst.size - offset)
readFullyOld
Link copied to clipboard
common
@JvmName(name = readFully)
fun Input.readFullyOld(dst: ByteArray, offset: Int = 0, length: Int = dst.size - offset)
@JvmName(name = readFully)
fun Input.readFullyOld(dst: DoubleArray, offset: Int = 0, length: Int = dst.size - offset)
@JvmName(name = readFully)
fun Input.readFullyOld(dst: FloatArray, offset: Int = 0, length: Int = dst.size - offset)
@JvmName(name = readFully)
fun Input.readFullyOld(dst: IntArray, offset: Int = 0, length: Int = dst.size - offset)
@JvmName(name = readFully)
fun Input.readFullyOld(dst: LongArray, offset: Int = 0, length: Int = dst.size - offset)
@JvmName(name = readFully)
fun Input.readFullyOld(dst: ShortArray, offset: Int = 0, length: Int = dst.size - offset)
readInt
Link copied to clipboard
common
fun Buffer.readInt(): Int
Read an integer or fail if not enough bytes available for reading.
fun Input.readInt(): Int
inline fun IoBuffer.readInt(): Int
fun Input.readInt(byteOrder: ByteOrder): Int
readIntLittleEndian
Link copied to clipboard
common
fun Buffer.readIntLittleEndian(): Int
fun Input.readIntLittleEndian(): Int
readLong
Link copied to clipboard
common
fun Buffer.readLong(): Long
Read a long integer or fail if not enough bytes available for reading.
fun Input.readLong(): Long
inline fun IoBuffer.readLong(): Long
fun Input.readLong(byteOrder: ByteOrder): Long
readLongLittleEndian
Link copied to clipboard
common
fun Buffer.readLongLittleEndian(): Long
fun Input.readLongLittleEndian(): Long
readShort
Link copied to clipboard
common
fun Buffer.readShort(): Short
Read a short integer or fail if no bytes available for reading.
fun Input.readShort(): Short
inline fun IoBuffer.readShort(): Short
fun Input.readShort(byteOrder: ByteOrder): Short
readShortLittleEndian
Link copied to clipboard
common
fun Buffer.readShortLittleEndian(): Short
fun Input.readShortLittleEndian(): Short
readText
Link copied to clipboard
common
fun Buffer.readText(charset: Charset = Charsets.UTF_8, max: Int = Int.MAX_VALUE): String
Reads at most max characters decoding bytes with specified charset.
common
fun Input.readText(charset: Charset = Charsets.UTF_8, max: Int = Int.MAX_VALUE): String
Reads at most max characters decoding bytes with specified charset.
common
fun Input.readText(decoder: CharsetDecoder, max: Int = Int.MAX_VALUE): String
Reads at most max characters decoding bytes with specified decoder.
fun ByteReadPacket.readText(decoder: CharsetDecoder, out: Appendable, max: Int = Int.MAX_VALUE): Int
fun Buffer.readText(decoder: CharsetDecoder, out: Appendable, lastBuffer: Boolean, max: Int = Int.MAX_VALUE): Int
common
fun Input.readText(out: Appendable, charset: Charset = Charsets.UTF_8, max: Int = Int.MAX_VALUE): Int
Reads at most max characters decoding bytes with specified charset.
common
fun Input.readText(out: Appendable, decoder: CharsetDecoder, max: Int = Int.MAX_VALUE): Int
Reads at most max characters decoding bytes with specified decoder.
readTextExact
Link copied to clipboard
common
fun Input.readTextExact(charset: Charset = Charsets.UTF_8, n: Int): String
Read exactly n characters interpreting bytes in the specified charset.
readTextExactBytes
Link copied to clipboard
common
fun Input.readTextExactBytes(charset: Charset = Charsets.UTF_8, bytes: Int): String
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).
readTextExactCharacters
Link copied to clipboard
common
fun Input.readTextExactCharacters(charactersCount: Int, charset: Charset = Charsets.UTF_8): String
Read exactly charactersCount characters interpreting bytes in the specified charset.
readUByte
Link copied to clipboard
common
fun Buffer.readUByte(): UByte
Read an unsigned byte or fail if no bytes available for reading.
inline fun Input.readUByte(): UByte
inline fun IoBuffer.readUByte(): UByte
readUInt
Link copied to clipboard
common
fun Buffer.readUInt(): UInt
Read an unsigned integer or fail if not enough bytes available for reading.
inline fun Input.readUInt(): UInt
inline fun IoBuffer.readUInt(): UInt
readULong
Link copied to clipboard
common
fun Buffer.readULong(): ULong
Read an unsigned long integer or fail if not enough bytes available for reading.
inline fun Input.readULong(): ULong
inline fun IoBuffer.readULong(): ULong
readUntilDelimiter
Link copied to clipboard
common
fun Input.readUntilDelimiter(delimiter: Byte, dst: Output): Long
Copies to dst output until the specified delimiter occurred.
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.
readUntilDelimiters
Link copied to clipboard
common
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 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.
readUShort
Link copied to clipboard
common
fun Buffer.readUShort(): UShort
Read an unsigned short integer or fail if not enough bytes available for reading.
inline fun Input.readUShort(): UShort
inline fun IoBuffer.readUShort(): UShort
readUTF8Line
Link copied to clipboard
common
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 null if the packet is empty
fun Input.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 null if the packet is empty
readUTF8LineTo
Link copied to clipboard
common
fun Input.readUTF8LineTo(out: Appendable, limit: Int): Boolean
Read UTF-8 line and append all line characters to out except line endings.
readUTF8UntilDelimiter
Link copied to clipboard
common
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
readUTF8UntilDelimiterTo
Link copied to clipboard
common
fun Input.readUTF8UntilDelimiterTo(out: BytePacketBuilderBase, 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.readUTF8UntilDelimiterTo(out: Appendable, 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
release
Link copied to clipboard
common
fun IoBuffer.release(pool: ObjectPool<IoBuffer>)
releases buffer view and returns it to the pool if there are no more usages.
remainingAll
Link copied to clipboard
common
fun ChunkBuffer.remainingAll(): Long
Summarize remainings of all elements of the chain
fun remainingAll(buffer: IoBuffer): Long
reset
Link copied to clipboard
common
fun BytePacketBuilder.reset()
Discard all written bytes and prepare to build another packet.
String
Link copied to clipboard
common
fun String(bytes: ByteArray, offset: Int = 0, length: Int = bytes.size, charset: Charset = Charsets.UTF_8): String
Create an instance of String from the specified bytes range starting at offset and bytes length interpreting characters in the specified charset.
posix
fun String(bytes: ByteArray, offset: Int = 0, length: Int = bytes.size, charset: Charset = Charsets.UTF_8): String
Create an instance of String from the specified bytes range starting at offset and bytes length interpreting characters in the specified charset.
takeWhile
Link copied to clipboard
common
inline fun Input.takeWhile(block: (Buffer) -> Boolean)
Invoke block function for every chunk until end of input or block function return falseblock function returns true to request more chunks or false to stop loopIt is not guaranteed that every chunk will have fixed size but it will be never empty.
takeWhileSize
Link copied to clipboard
common
inline fun Input.takeWhileSize(initialSize: Int = 1, block: (Buffer) -> Int)
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.
toByteArray
Link copied to clipboard
common
inline fun String.toByteArray(charset: Charset = Charsets.UTF_8): ByteArray
tryPeek
Link copied to clipboard
common
fun Buffer.tryPeek(): Int
Peek the next unsigned byte or return -1 if no more bytes available for reading.
use
Link copied to clipboard
common
inline fun <C : Closeable, R> C.use(block: (C) -> R): R
withBuffer
Link copied to clipboard
common
inline fun <R> withBuffer(pool: ObjectPool<Buffer>, block: Buffer.() -> R): R
Invoke block function with a temporary Buffer instance taken from the specified pool.
inline fun <R> withBuffer(size: Int, block: Buffer.() -> R): R
Invoke block function with a temporary Buffer instance of the specified size in bytes.
write
Link copied to clipboard
common
inline fun Buffer.write(block: (memory: Memory, start: Int, endExclusive: Int) -> Int): Int
Apply block of code with buffer's memory providing write range indices.
writeByteBufferDirect
Link copied to clipboard
inline fun BytePacketBuilder.writeByteBufferDirect(size: Int, block: (ByteBuffer) -> Unit): Int
Write bytes directly to packet builder's segment.
writeDirect
Link copied to clipboard
inline fun Buffer.writeDirect(block: (<ERROR CLASS><<ERROR CLASS>>) -> Int): Int
inline fun Buffer.writeDirect(size: Int = 1, block: (ByteBuffer) -> Unit): Int
inline fun BytePacketBuilder.writeDirect(size: Int, block: (ByteBuffer) -> Unit)
Write bytes directly to packet builder's segment.
writeDouble
Link copied to clipboard
common
fun Buffer.writeDouble(value: Double)
Write a floating point number or fail if not enough space available for writing.
inline fun IoBuffer.writeDouble(value: Double)
fun Output.writeDouble(value: Double)
fun Output.writeDouble(value: Double, byteOrder: ByteOrder)
writeDoubleLittleEndian
Link copied to clipboard
common
fun Buffer.writeDoubleLittleEndian(value: Double)
fun Output.writeDoubleLittleEndian(value: Double)
writeFloat
Link copied to clipboard
common
fun Buffer.writeFloat(value: Float)
Write a floating point number or fail if not enough space available for writing.
inline fun IoBuffer.writeFloat(value: Float)
fun Output.writeFloat(value: Float)
fun Output.writeFloat(value: Float, byteOrder: ByteOrder)
writeFloatLittleEndian
Link copied to clipboard
common
fun Buffer.writeFloatLittleEndian(value: Float)
fun Output.writeFloatLittleEndian(value: Float)
writeFully
Link copied to clipboard
common
fun Buffer.writeFully(src: Buffer)
Write all readable bytes from src to this buffer.
fun Buffer.writeFully(source: ByteBuffer)
Write source buffer content moving it's position.
fun BytePacketBuilder.writeFully(src: ByteBuffer)
Write all src buffer remaining bytes and change it's position accordingly
fun Output.writeFully(bb: ByteBuffer)
fun Output.writeFully(src: Buffer, length: Int = src.readRemaining)
fun Output.writeFully(src: IoBuffer, length: Int = src.readRemaining)
inline fun IoBuffer.writeFully(source: ByteArray, offset: Int = 0, length: Int = source.size - offset)
fun Output.writeFully(src: Memory, offset: Int, length: Int)
fun Output.writeFully(src: Memory, offset: Long, length: Long)
fun Output.writeFully(src: ByteArray, offset: Int = 0, length: Int = src.size - offset)
fun Output.writeFully(src: DoubleArray, offset: Int = 0, length: Int = src.size - offset)
fun Output.writeFully(src: FloatArray, offset: Int = 0, length: Int = src.size - offset)
fun Output.writeFully(src: IntArray, offset: Int = 0, length: Int = src.size - offset)
fun Output.writeFully(src: LongArray, offset: Int = 0, length: Int = src.size - offset)
fun Output.writeFully(src: ShortArray, offset: Int = 0, length: Int = src.size - offset)
inline fun Output.writeFully(array: UByteArray, offset: Int = 0, length: Int = array.size - offset)
inline fun Output.writeFully(array: UIntArray, offset: Int = 0, length: Int = array.size - offset)
inline fun Output.writeFully(array: ULongArray, offset: Int = 0, length: Int = array.size - offset)
inline fun Output.writeFully(array: UShortArray, offset: Int = 0, length: Int = array.size - offset)
fun Buffer.writeFully(pointer: <ERROR CLASS><<ERROR CLASS>>, offset: Int, length: Int)
fun Buffer.writeFully(pointer: <ERROR CLASS><<ERROR CLASS>>, offset: Long, length: Int)
fun Output.writeFully(src: <ERROR CLASS><<ERROR CLASS>>, offset: Int, length: Int)
fun Output.writeFully(src: <ERROR CLASS><<ERROR CLASS>>, offset: Long, length: Long)
common
fun Buffer.writeFully(src: Buffer, length: Int)
Write at most length readable bytes from src to this buffer.
posix
fun BytePacketBuilder.writeFully(src: <ERROR CLASS><<ERROR CLASS>>, size: Int)
Write all src buffer remaining bytes and change it's position accordingly
common
fun Buffer.writeFully(source: ByteArray, offset: Int = 0, length: Int = source.size - offset)
Write the whole source array range staring at offset and having the specified bytes length.
common
fun Buffer.writeFully(source: DoubleArray, offset: Int = 0, length: Int = source.size - offset)
Write the whole source array range staring at offset and having the specified items length.
common
fun Buffer.writeFully(source: FloatArray, offset: Int = 0, length: Int = source.size - offset)
Write the whole source array range staring at offset and having the specified items length.
common
fun Buffer.writeFully(source: IntArray, offset: Int = 0, length: Int = source.size - offset)
Write the whole source array range staring at offset and having the specified items length.
common
fun Buffer.writeFully(source: LongArray, offset: Int = 0, length: Int = source.size - offset)
Write the whole source array range staring at offset and having the specified items length.
common
fun Buffer.writeFully(source: ShortArray, offset: Int = 0, length: Int = source.size - offset)
Write the whole source array range staring at offset and having the specified items length.
common
fun Buffer.writeFully(source: UByteArray, offset: Int = 0, length: Int = source.size - offset)
Write the whole source array range staring at offset and having the specified bytes length.
common
fun Buffer.writeFully(source: UIntArray, offset: Int = 0, length: Int = source.size - offset)
Write the whole source array range staring at offset and having the specified items length.
common
fun Buffer.writeFully(source: ULongArray, offset: Int = 0, length: Int = source.size - offset)
Write the whole source array range staring at offset and having the specified items length.
common
fun Buffer.writeFully(source: UShortArray, offset: Int = 0, length: Int = source.size - offset)
Write the whole source array range staring at offset and having the specified items length.
writeFullyLittleEndian
Link copied to clipboard
common
fun Buffer.writeFullyLittleEndian(source: DoubleArray, offset: Int = 0, length: Int = source.size - offset)
fun Buffer.writeFullyLittleEndian(source: FloatArray, offset: Int = 0, length: Int = source.size - offset)
fun Buffer.writeFullyLittleEndian(source: IntArray, offset: Int = 0, length: Int = source.size - offset)
fun Buffer.writeFullyLittleEndian(source: LongArray, offset: Int = 0, length: Int = source.size - offset)
fun Buffer.writeFullyLittleEndian(source: ShortArray, offset: Int = 0, length: Int = source.size - offset)
fun Buffer.writeFullyLittleEndian(source: UIntArray, offset: Int = 0, length: Int = source.size - offset)
fun Buffer.writeFullyLittleEndian(source: ULongArray, offset: Int = 0, length: Int = source.size - offset)
fun Buffer.writeFullyLittleEndian(source: UShortArray, offset: Int = 0, length: Int = source.size - offset)
fun Output.writeFullyLittleEndian(source: DoubleArray, offset: Int = 0, length: Int = source.size - offset)
fun Output.writeFullyLittleEndian(source: FloatArray, offset: Int = 0, length: Int = source.size - offset)
fun Output.writeFullyLittleEndian(source: IntArray, offset: Int = 0, length: Int = source.size - offset)
fun Output.writeFullyLittleEndian(source: LongArray, offset: Int = 0, length: Int = source.size - offset)
fun Output.writeFullyLittleEndian(source: ShortArray, offset: Int = 0, length: Int = source.size - offset)
fun Output.writeFullyLittleEndian(source: UIntArray, offset: Int = 0, length: Int = source.size - offset)
fun Output.writeFullyLittleEndian(source: ULongArray, offset: Int = 0, length: Int = source.size - offset)
fun Output.writeFullyLittleEndian(source: UShortArray, offset: Int = 0, length: Int = source.size - offset)
writeInt
Link copied to clipboard
common
fun Buffer.writeInt(value: Int)
Write an integer or fail if not enough space available for writing.
inline fun IoBuffer.writeInt(value: Int)
fun Output.writeInt(value: Int)
fun Output.writeInt(value: Int, byteOrder: ByteOrder)
writeIntLittleEndian
Link copied to clipboard
common
fun Buffer.writeIntLittleEndian(value: Int)
fun Output.writeIntLittleEndian(value: Int)
writeLong
Link copied to clipboard
common
fun Buffer.writeLong(value: Long)
Write a long integer or fail if not enough space available for writing.
inline fun IoBuffer.writeLong(value: Long)
fun Output.writeLong(value: Long)
fun Output.writeLong(value: Long, byteOrder: ByteOrder)
writeLongLittleEndian
Link copied to clipboard
common
fun Buffer.writeLongLittleEndian(value: Long)
fun Output.writeLongLittleEndian(value: Long)
writePacket
Link copied to clipboard
common
fun Output.writePacket(packet: ByteReadPacket)
writeShort
Link copied to clipboard
common
fun Buffer.writeShort(value: Short)
Write a short integer or fail if not enough space available for writing.
inline fun IoBuffer.writeShort(value: Short)
fun Output.writeShort(value: Short)
fun Output.writeShort(value: Short, byteOrder: ByteOrder)
writeShortLittleEndian
Link copied to clipboard
common
fun Buffer.writeShortLittleEndian(value: Short)
fun Output.writeShortLittleEndian(value: Short)
writeText
Link copied to clipboard
common
fun Output.writeText(text: CharArray, fromIndex: Int = 0, toIndex: Int = text.size, charset: Charset = Charsets.UTF_8)
Writes text characters in range \[fromIndex ..
fun Output.writeText(text: CharSequence, fromIndex: Int = 0, toIndex: Int = text.length, charset: Charset = Charsets.UTF_8)
Writes text characters in range \[fromIndex ..
fun Output.writeText(text: CharSequence, fromIndex: Int = 0, toIndex: Int = text.length, encoder: CharsetEncoder)
Writes text characters in range \[fromIndex ..
writeUByte
Link copied to clipboard
common
fun Buffer.writeUByte(value: UByte)
Write an unsigned byte or fail if not enough space available for writing.
fun IoBuffer.writeUByte(value: UByte)
inline fun Output.writeUByte(v: UByte)
writeUInt
Link copied to clipboard
common
fun Buffer.writeUInt(value: UInt)
Write an unsigned integer or fail if not enough space available for writing.
inline fun IoBuffer.writeUInt(value: UInt)
inline fun Output.writeUInt(v: UInt)
writeULong
Link copied to clipboard
common
fun Buffer.writeULong(value: ULong)
Write an unsigned long integer or fail if not enough space available for writing.
inline fun IoBuffer.writeULong(value: ULong)
inline fun Output.writeULong(v: ULong)
writeUShort
Link copied to clipboard
common
fun Buffer.writeUShort(value: UShort)
Write an unsigned short integer or fail if not enough space available for writing.
inline fun IoBuffer.writeUShort(value: UShort)
inline fun Output.writeUShort(v: UShort)
writeWhile
Link copied to clipboard
common
inline fun Output.writeWhile(block: (Buffer) -> Boolean)
Append number of chunks invoking block function while the returned value is true.
writeWhileSize
Link copied to clipboard
common
inline fun Output.writeWhileSize(initialSize: Int = 1, block: (Buffer) -> Int)
Append number of chunks invoking block function while the returned value is positive.

Properties

byteOrder
Link copied to clipboard
common
var Buffer.byteOrder: ByteOrder
isEmpty
Link copied to clipboard
common
val Input.isEmpty: Boolean
For streaming input it should be Input.endOfInput instead.
isEmpty
Link copied to clipboard
common
val ByteReadPacket.isEmpty: Boolean
isNotEmpty
Link copied to clipboard
common
val Input.isNotEmpty: Boolean
For streaming input there is no reliable way to detect it without triggering bytes population from the underlying source.
isNotEmpty
Link copied to clipboard
common
val ByteReadPacket.isNotEmpty: Boolean
PACKET_MAX_COPY_SIZE
Link copied to clipboard
val PACKET_MAX_COPY_SIZE: Int = 200