
com.avsystem.commons.kafka.CodecSerde.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-kafka_2.12 Show documentation
Show all versions of commons-kafka_2.12 Show documentation
AVSystem commons library for Scala
The newest version!
package com.avsystem.commons
package kafka
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, DataInputStream, DataOutputStream}
import com.avsystem.commons.serialization.{GenCodec, StreamInput, StreamOutput}
private[kafka] class CodecSerde[T](codec: GenCodec[T]) {
def deserialize(in: ByteArrayInputStream): T = {
val input = new StreamInput(new DataInputStream(in))
codec.read(input)
}
def serialize(out: ByteArrayOutputStream, data: T): Array[Byte] = {
val output = new StreamOutput(new DataOutputStream(out))
codec.write(output, data)
out.toByteArray
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy