readAvailable

fun Buffer.readAvailable(
    destination: ByteArray,
    offset: Int = 0,
    length: Int = destination.size - offset
): Int
fun Buffer.readAvailable(
    destination: <ERROR CLASS>,
    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. If less than length bytes available then less bytes will be copied and the corresponding number will be returned as result.

Return number of bytes copied to the destination or -1 if the buffer is empty

inline fun IoBuffer.readAvailable(
    destination: ByteArray,
    offset: Int = 0,
    length: Int = destination.size - offset
): Int

Deprecated: IoBuffer is deprecated. Use Memory or Input instead.

fun Input.readAvailable(
    dst: IoBuffer,
    size: Int = dst.writeRemaining
): Int

Deprecated: Binary compatibility.

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 Buffer.readAvailable(
    dst: ByteBuffer,
    length: Int = dst.remaining()
): Int
fun Buffer.readAvailable(
    destination: ShortArray,
    offset: Int = 0,
    length: Int = destination.size - offset
): Int
fun Buffer.readAvailable(
    destination: IntArray,
    offset: Int = 0,
    length: Int = destination.size - offset
): Int
fun Buffer.readAvailable(
    destination: LongArray,
    offset: Int = 0,
    length: Int = destination.size - offset
): Int
fun Buffer.readAvailable(
    destination: FloatArray,
    offset: Int = 0,
    length: Int = destination.size - offset
): Int
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. If less than length elements available then less elements will be copied and the corresponding number will be returned as result (possibly zero).

Return number of elements copied to the destination or -1 if the buffer is empty, 0 - not enough bytes for at least an element

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.

Return number of bytes copied or -1 if empty

fun ByteReadPacket.readAvailable(dst: ByteBuffer): Int

Read at most dst.remaining() bytes to the specified dst byte buffer and change it’s position accordingly

Return number of bytes copied