ByteArrayBinaryData

class ByteArrayBinaryData(data: ByteArray, offset: Int = 0, length: Int = data.size - offset) : RpcBinaryData

RpcBinaryData backed by an in-memory ByteArray. Avoids all streaming and coroutine overhead — transferTo delivers the entire buffer in a single callback, and toByteArray returns the array directly.

Constructors

Link copied to clipboard
constructor(data: ByteArray, offset: Int = 0, length: Int = data.size - offset)

Properties

Link copied to clipboard
open override val size: Long

Known byte length, or null for unknown / streaming sources.

Functions

Link copied to clipboard
open suspend override fun close()
Link copied to clipboard
open suspend override fun toByteArray(): ByteArray

Drain this source into a single ByteArray. Default implementation accumulates transferTo chunks; subclasses that already hold the data in memory should override this to return it directly.

Link copied to clipboard
open suspend override fun transferTo(sink: suspend (bytes: ByteArray, offset: Int, length: Int) -> Unit)

Pull all bytes from this source into sink. The sink callback may be invoked many times with different offsets / lengths into a buffer the implementation owns; callers must not retain the bytes array beyond the duration of the call.