All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.avrokotlin.avro4k.internal.AvroInternalExtensions.kt Maven / Gradle / Ivy

Go to download

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)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy