1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

make ByteReadChannelAllocatorSerializer -> ByteReadChannelAllocatorDeserializationStrategy

This commit is contained in:
InsanusMokrassar 2021-08-10 10:12:22 +06:00
parent c66d64adbc
commit c8ad68ea69
2 changed files with 4 additions and 11 deletions

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.requests
import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.utils.ByteReadChannelAllocator import dev.inmo.tgbotapi.utils.ByteReadChannelAllocator
import dev.inmo.tgbotapi.utils.ByteReadChannelAllocatorSerializer import dev.inmo.tgbotapi.utils.ByteReadChannelAllocatorDeserializationStrategy
import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.DeserializationStrategy
class DownloadFileStream( class DownloadFileStream(
@ -10,6 +10,6 @@ class DownloadFileStream(
) : Request<ByteReadChannelAllocator> { ) : Request<ByteReadChannelAllocator> {
override fun method(): String = filePath override fun method(): String = filePath
override val resultDeserializer: DeserializationStrategy<ByteReadChannelAllocator> override val resultDeserializer: DeserializationStrategy<ByteReadChannelAllocator>
get() = ByteReadChannelAllocatorSerializer get() = ByteReadChannelAllocatorDeserializationStrategy
} }

View File

@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.utils
import dev.inmo.micro_utils.common.ByteArrayAllocatorSerializer import dev.inmo.micro_utils.common.ByteArrayAllocatorSerializer
import io.ktor.utils.io.ByteReadChannel import io.ktor.utils.io.ByteReadChannel
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.KSerializer import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
@ -11,17 +12,9 @@ fun interface ByteReadChannelAllocator {
suspend operator fun invoke(): ByteReadChannel suspend operator fun invoke(): ByteReadChannel
} }
object ByteReadChannelAllocatorSerializer : KSerializer<ByteReadChannelAllocator> { object ByteReadChannelAllocatorDeserializationStrategy : DeserializationStrategy<ByteReadChannelAllocator> {
override val descriptor: SerialDescriptor = ByteArrayAllocatorSerializer.descriptor override val descriptor: SerialDescriptor = ByteArrayAllocatorSerializer.descriptor
override fun serialize(encoder: Encoder, value: ByteReadChannelAllocator) {
TODO("Not yet implemented")
// ByteArrayAllocatorSerializer.serialize(
// encoder
// ) {
// }
}
override fun deserialize(decoder: Decoder): ByteReadChannelAllocator { override fun deserialize(decoder: Decoder): ByteReadChannelAllocator {
val byteArrayAllocator = ByteArrayAllocatorSerializer.deserialize(decoder) val byteArrayAllocator = ByteArrayAllocatorSerializer.deserialize(decoder)
return ByteReadChannelAllocator { ByteReadChannel(byteArrayAllocator()) } return ByteReadChannelAllocator { ByteReadChannel(byteArrayAllocator()) }