Serializer

object Serializer
Companion
class
class Object
trait Matchable
class Any

Value members

Concrete methods

def apply[F[_], A](serializer: Serializer[F, A]): Serializer[F, A]
def apply[F[_]](F: Sync[F]): Serializer[F, Array[Byte]]
def asNull[F[_], A](F: Sync[F]): Serializer[F, A]

Creates a new Serializer which serializes all values of type A as null.

Creates a new Serializer which serializes all values of type A as null.

def const[F[_], A](bytes: Array[Byte])(F: Sync[F]): Serializer[F, A]

Creates a new Serializer which serializes all values of type A to the specified bytes.

Creates a new Serializer which serializes all values of type A to the specified bytes.

def delegate[F[_], A](serializer: Serializer[A])(F: Sync[F]): Serializer[F, A]

Creates a new Serializer which delegates serialization to the specified Kafka Serializer. Note the close and configure functions won't be called for the delegate.

It is assumed the delegate serialize function is pure. If it's not pure, then use suspend after delegate, so the impure behaviours can be captured properly.

Creates a new Serializer which delegates serialization to the specified Kafka Serializer. Note the close and configure functions won't be called for the delegate.

It is assumed the delegate serialize function is pure. If it's not pure, then use suspend after delegate, so the impure behaviours can be captured properly.

def empty[F[_], A](F: Sync[F]): Serializer[F, A]

Creates a new Serializer which serializes all values of type A as the empty Array[Byte].

Creates a new Serializer which serializes all values of type A as the empty Array[Byte].

def fail[F[_], A](e: Throwable)(F: Sync[F]): Serializer[F, A]

Creates a new Serializer which always fails serialization with the specified exception e.

Creates a new Serializer which always fails serialization with the specified exception e.

def failWith[F[_], A](message: String)(F: Sync[F]): Serializer[F, A]

Creates a new Serializer which always fails serialization with a SerializationException using the specified message.

Creates a new Serializer which always fails serialization with a SerializationException using the specified message.

def headers[F[_], A](f: Headers => Serializer[F, A])(F: Sync[F]): Serializer[F, A]

Creates a new Serializer which can use different Serializers depending on the record headers.

Creates a new Serializer which can use different Serializers depending on the record headers.

def instance[F[_], A](f: (String, Headers, A) => F[Array[Byte]])(F: Sync[F]): Serializer[F, A]

Creates a new Serializer from the specified function. Use lift instead if the serializer doesn't need access to the Kafka topic name or record headers.

Creates a new Serializer from the specified function. Use lift instead if the serializer doesn't need access to the Kafka topic name or record headers.

def lift[F[_], A](f: A => F[Array[Byte]])(F: Sync[F]): Serializer[F, A]

Creates a new Serializer from the specified function, ignoring to which Kafka topic the bytes are going to be sent and any record headers. Use instance instead if the serializer needs access to the Kafka topic name or the record headers.

Creates a new Serializer from the specified function, ignoring to which Kafka topic the bytes are going to be sent and any record headers. Use instance instead if the serializer needs access to the Kafka topic name or the record headers.

def string[F[_]](charset: Charset)(F: Sync[F]): Serializer[F, String]

Creates a new Serializer which serializes String values using the specified Charset. Note that the default String serializer uses UTF-8.

Creates a new Serializer which serializes String values using the specified Charset. Note that the default String serializer uses UTF-8.

def topic[F[_], A](f: PartialFunction[String, Serializer[F, A]])(F: Sync[F]): Serializer[F, A]

Creates a new Serializer which can use different Serializers depending on the Kafka topic name to which the bytes are going to be sent.

Creates a new Serializer which can use different Serializers depending on the Kafka topic name to which the bytes are going to be sent.

def uuid[F[_]](charset: Charset)(F: Sync[F]): Serializer[F, UUID]

Creates a new Serializer which serializes UUID values as Strings with the specified Charset. Note that the default UUID serializer uses UTF-8.

Creates a new Serializer which serializes UUID values as Strings with the specified Charset. Note that the default UUID serializer uses UTF-8.

Implicits

Implicits

implicit def contravariant[F[_]]: Contravariant[[_] =>> Serializer[F, _$25]]
implicit def double[F[_]](F: Sync[F]): Serializer[F, Double]
implicit def float[F[_]](F: Sync[F]): Serializer[F, Float]
implicit def identity[F[_]](F: Sync[F]): Serializer[F, Array[Byte]]

The identity Serializer, which does not perform any kind of serialization, simply using the input bytes as the output.

The identity Serializer, which does not perform any kind of serialization, simply using the input bytes as the output.

implicit def int[F[_]](F: Sync[F]): Serializer[F, Int]
implicit def long[F[_]](F: Sync[F]): Serializer[F, Long]
implicit def option[F[_], A](serializer: Serializer[F, A]): Serializer[F, Option[A]]

The option Serializer serializes None as null, and serializes Some values using the serializer for type A.

The option Serializer serializes None as null, and serializes Some values using the serializer for type A.

implicit def short[F[_]](F: Sync[F]): Serializer[F, Short]
implicit def string[F[_]](F: Sync[F]): Serializer[F, String]
implicit def unit[F[_]](F: Sync[F]): Serializer[F, Unit]
implicit def uuid[F[_]](F: Sync[F]): Serializer[F, UUID]