Не подтверждена Коммит e3505c6b создал по автору Sergey Mashkov's avatar Sergey Mashkov
Просмотр файлов

Move minor CIO utils to common

владелец 13483b00
......@@ -438,8 +438,11 @@ public final class io/ktor/util/cio/OutputStreamAdaptersKt {
public static synthetic fun writer$default (Lio/ktor/utils/io/ByteWriteChannel;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/io/Writer;
}
public final class io/ktor/util/cio/ReadersKt {
public final class io/ktor/util/cio/ReadersJvmKt {
public static final fun pass (Lio/ktor/utils/io/ByteReadChannel;Ljava/nio/ByteBuffer;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class io/ktor/util/cio/ReadersKt {
public static final fun toByteArray (Lio/ktor/utils/io/ByteReadChannel;ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun toByteArray$default (Lio/ktor/utils/io/ByteReadChannel;ILkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun use (Lio/ktor/utils/io/ByteWriteChannel;Lkotlin/jvm/functions/Function1;)V
......
......@@ -14,10 +14,11 @@ import io.ktor.util.cio.*
import io.ktor.util.pipeline.*
import kotlinx.coroutines.*
import io.ktor.utils.io.*
import io.ktor.utils.io.charsets.*
import io.ktor.utils.io.jvm.javaio.*
import io.ktor.utils.io.streams.*
import java.io.*
import java.nio.charset.*
import kotlin.text.*
private val ReusableTypes = arrayOf(ByteArray::class, String::class, Parameters::class)
......
......@@ -4,7 +4,7 @@
package io.ktor.util.cio
import java.io.*
import io.ktor.utils.io.errors.*
/**
* An exception thrown when an IO error occurred during reading or writing to/from the underlying channel.
......
......@@ -4,10 +4,8 @@
package io.ktor.util.cio
import io.ktor.util.*
import io.ktor.utils.io.*
import io.ktor.utils.io.core.*
import java.nio.*
import kotlin.contracts.*
/**
......@@ -16,20 +14,6 @@ import kotlin.contracts.*
suspend fun ByteReadChannel.toByteArray(limit: Int = Int.MAX_VALUE): ByteArray =
readRemaining(limit.toLong()).readBytes()
/**
* Read data chunks from [ByteReadChannel] using buffer
*/
@InternalAPI
suspend inline fun ByteReadChannel.pass(buffer: ByteBuffer, block: (ByteBuffer) -> Unit) {
while (!isClosedForRead) {
buffer.clear()
readAvailable(buffer)
buffer.flip()
block(buffer)
}
}
/**
* Executes [block] on [ByteWriteChannel] and close it down correctly whether an exception
*/
......
/*
* Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package io.ktor.util.cio
import io.ktor.util.*
import io.ktor.utils.io.*
import java.nio.*
/**
* Read data chunks from [ByteReadChannel] using buffer
*/
@InternalAPI
suspend inline fun ByteReadChannel.pass(buffer: ByteBuffer, block: (ByteBuffer) -> Unit) {
while (!isClosedForRead) {
buffer.clear()
readAvailable(buffer)
buffer.flip()
block(buffer)
}
}
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать