com.github.avrokotlin.avro4k.internal.AvroInternalExtensions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of avro4k-core Show documentation
Show all versions of avro4k-core Show documentation
Avro binary format support for kotlin, built on top of kotlinx-serialization
The newest version!
package com.github.avrokotlin.avro4k.internal
import com.github.avrokotlin.avro4k.Avro
import com.github.avrokotlin.avro4k.internal.decoder.direct.AvroValueDirectDecoder
import com.github.avrokotlin.avro4k.internal.encoder.direct.AvroValueDirectEncoder
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerializationStrategy
import org.apache.avro.Schema
internal fun Avro.encodeWithBinaryEncoder(
writerSchema: Schema,
serializer: SerializationStrategy,
value: T,
binaryEncoder: org.apache.avro.io.Encoder,
) {
AvroValueDirectEncoder(writerSchema, this, binaryEncoder)
.encodeSerializableValue(serializer, value)
}
internal fun Avro.decodeWithBinaryDecoder(
writerSchema: Schema,
deserializer: DeserializationStrategy,
binaryDecoder: org.apache.avro.io.Decoder,
): T {
return AvroValueDirectDecoder(writerSchema, this, binaryDecoder)
.decodeSerializableValue(deserializer)
}