ByteReadChannel

interface ByteReadChannel : ObjectWrapper<ERROR CLASS: Symbol not found for io.ktor.utils.io.ByteReadChannel>

用于异步读取字节序列的通道。

该接口是对 Ktor 原始 io.ktor.utils.io.ByteReadChannel 的封装, 用于在脚本环境中提供非阻塞的IO读取能力。

这是一个 单读取者通道,意味着不应在多个协程中并发地从此通道读取数据。

Author

M8Test, [email protected], https://m8test.com

Functions

Link copied to clipboard
abstract fun also(block: (ERROR CLASS: Symbol not found for io.ktor.utils.io.ByteReadChannel) -> Unit): ObjectWrapper<ERROR CLASS: Symbol not found for io.ktor.utils.io.ByteReadChannel>

对 ObjectWrapper 调用给定的 block 函数,并返回 ObjectWrapper 本身。

Link copied to clipboard
abstract fun apply(block: ERROR CLASS: Symbol not found for io.ktor.utils.io.ByteReadChannel.() -> Unit): ObjectWrapper<ERROR CLASS: Symbol not found for io.ktor.utils.io.ByteReadChannel>

对 ObjectWrapper 调用给定的 block 函数,并返回 ObjectWrapper 本身。

Link copied to clipboard
abstract fun cancel(cause: Throwable?)

取消此通道。

Link copied to clipboard
abstract fun copyToByteWriteChannel(scope: CoroutineScope, byteWriteChannel: ByteWriteChannel, limit: Long?): Deferred<Long>

异步地将此通道中的字节复制到目标 byteWriteChannel 中.

Link copied to clipboard

异步地将此通道中所有剩余的字节复制到目标 byteWriteChannel 中,并在完成后关闭两个通道。

Link copied to clipboard
abstract fun discard(scope: CoroutineScope, max: Long): Deferred<Long>

异步丢弃(跳过)此通道中最多 max 个字节。

Link copied to clipboard
abstract fun getOrigin(): ERROR CLASS: Symbol not found for io.ktor.utils.io.ByteReadChannel

获取原始的对象.

Link copied to clipboard
abstract fun isClosedForRead(): Boolean

检查通道是否已对读取操作关闭。

Link copied to clipboard
abstract fun <R> let(block: (ERROR CLASS: Symbol not found for io.ktor.utils.io.ByteReadChannel) -> R): ObjectWrapper<R>?

对 ObjectWrapper 调用给定的 block 函数,并返回 block 函数的结果包装在 ObjectWrapper 中。

Link copied to clipboard
abstract fun readAvailable(scope: CoroutineScope, buffer: ByteArray, offset: Int, length: Int): Deferred<Int>

异步地将通道中当前可用的字节读入指定的字节数组.

Link copied to clipboard
abstract fun readByte(scope: CoroutineScope): Deferred<Byte>

异步读取并返回通道中的下一个字节。

Link copied to clipboard
abstract fun readByteArray(scope: CoroutineScope, count: Int): Deferred<ByteArray>

异步读取并返回一个包含确切 count 字节的字节数组。

Link copied to clipboard
abstract fun readInt(scope: CoroutineScope): Deferred<Int>

异步读取四个字节并将其作为 Int (大端序) 返回。

Link copied to clipboard
abstract fun readRemaining(scope: CoroutineScope, max: Long?): Deferred<Source>

异步读取此通道中所有剩余的字节。

Link copied to clipboard
abstract fun readStream(bufferSize: Int): Flow<ByteArray>

以冷流(Cold Flow)的形式返回一个字节块序列,用于流式读取此通道的数据。

Link copied to clipboard
abstract fun readUTF8Line(scope: CoroutineScope, max: Int?): Deferred<String?>

异步读取一行 UTF-8 编码的文本。 识别 CR, LF, CRLF 作为行分隔符。

Link copied to clipboard
abstract fun <R> run(block: ERROR CLASS: Symbol not found for io.ktor.utils.io.ByteReadChannel.() -> R): ObjectWrapper<R>?

对 ObjectWrapper 调用给定的 block 函数,并返回 block 函数的结果包装在 ObjectWrapper 中。

Link copied to clipboard
abstract fun setOrigin(origin: ERROR CLASS: Symbol not found for io.ktor.utils.io.ByteReadChannel)

设置原始对象

Link copied to clipboard
abstract fun takeIf(predicate: (ERROR CLASS: Symbol not found for io.ktor.utils.io.ByteReadChannel) -> Boolean): ObjectWrapper<ERROR CLASS: Symbol not found for io.ktor.utils.io.ByteReadChannel>?

如果 ObjectWrapper 满足给定的 predicate,则返回 ObjectWrapper 本身,否则返回 null 包装在 ObjectWrapper? 中。

Link copied to clipboard
abstract fun takeUnless(predicate: (ERROR CLASS: Symbol not found for io.ktor.utils.io.ByteReadChannel) -> Boolean): ObjectWrapper<ERROR CLASS: Symbol not found for io.ktor.utils.io.ByteReadChannel>?

如果 ObjectWrapper 不满足给定的 predicate,则返回 ObjectWrapper 本身,否则返回 null 包装在 ObjectWrapper? 中。