ByteReadChannelBinaryData

class ByteReadChannelBinaryData(channel: ByteReadChannel, val size: Long? = null) : RpcBinaryData

Bridge from ktor's ByteReadChannel onto the transport-agnostic RpcBinaryData interface. Lives here (rather than in ksrpc-core) so that ksrpc-core does not publicly depend on ktor — consumers opt in to the ktor-io adapter by adding ksrpc-binary-ktor to their classpath.

Constructors

Link copied to clipboard
constructor(channel: ByteReadChannel, size: Long? = null)

Properties

Link copied to clipboard
open override val size: Long?

Functions

Link copied to clipboard
fun RpcBinaryData.asByteReadChannel(scope: CoroutineScope = CoroutineScope(Dispatchers.Default)): ByteReadChannel

Expose an RpcBinaryData as a ByteReadChannel. Unwraps directly when the underlying data is already a ByteReadChannelBinaryData; otherwise spins up a pump coroutine that drains RpcBinaryData.transferTo into a new ktor ByteChannel.

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