Encoder

object Encoder extends LowPrioEncoders
Companion:
class
class Object
trait Matchable
class Any
Encoder.type

Type members

Classlikes

final class ConcatEncoder[T](encoder0: Encoder[T], encoder1: Encoder[T], maxBufferSize: Int) extends Encoder[T]

Creates a new Encoder which emits the flat, concatenated encoding of two other encoders. Only works with encoders that encode to arrays or maps and both encoders must be of the same type, i.e. both encode to an array or both encode to a map. If the encoders are incompatible or produce elements that are not wrapped in an array or map each encoding attempt will fail with a Borer.Error.Unsupported exception.

Creates a new Encoder which emits the flat, concatenated encoding of two other encoders. Only works with encoders that encode to arrays or maps and both encoders must be of the same type, i.e. both encode to an array or both encode to a map. If the encoders are incompatible or produce elements that are not wrapped in an array or map each encoding attempt will fail with a Borer.Error.Unsupported exception.

Value parameters:
maxBufferSize

the maximum size of the buffer for the encoding of the first encoder

trait DefaultValueAware[T] extends Encoder[T]

An Encoder that might change its encoding strategy if T has a default value.

An Encoder that might change its encoding strategy if T has a default value.

object ForEither

The default Encoder for Either is not automatically in scope, because there is no clear "standard" way of encoding instances of Either.

The default Encoder for Either is not automatically in scope, because there is no clear "standard" way of encoding instances of Either.

trait Lazy[T] extends Encoder[T]

An Encoder that lazily wraps another Encoder. Useful, for example, for recursive definitions.

An Encoder that lazily wraps another Encoder. Useful, for example, for recursive definitions.

trait PossiblyWithoutOutput[T] extends Encoder[T]

An Encoder that might not actually produce any output for certain values of T (e.g. because "not-present" already carries sufficient information).

An Encoder that might not actually produce any output for certain values of T (e.g. because "not-present" already carries sufficient information).

Value members

Concrete methods

def apply[T](implicit encoder: Encoder[T]): Encoder[T]

Creates an Encoder from the given function.

Creates an Encoder from the given function.

def forByteArray(jsonBaseEncoding: BaseEncoding): Encoder[Array[Byte]]
inline def forProduct[T <: Product](implicit m: ProductOf[T]): Encoder[T]

Creates an Encoder that encodes a product instance as a simple array of values. Used, for example, as the default 'given' encoder for tuples.

Creates an Encoder that encodes a product instance as a simple array of values. Used, for example, as the default 'given' encoder for tuples.

def targetSpecific[T](cbor: Encoder[T], json: Encoder[T]): Encoder[T]

Creates a "unified" Encoder from two encoders that each target only a single data format.

Creates a "unified" Encoder from two encoders that each target only a single data format.

Extensions

Extensions

extension [A](underlying: Encoder[A])
def contramap[B](f: B => A): Encoder[B]
def contramapWithWriter[B](f: (Writer, B) => A): Encoder[B]
def unwrap: Encoder[A]
def withDefaultValue(defaultValue: A): Encoder[A]
extension [T](underlying: => Encoder[T])
def concat(other: Encoder[T], maxBufferSize: Int): Encoder[T]

Creates a new Encoder which emits the flat, concatenated encoding of the underlying encoder and the given other one. Only works with encoders that encode to arrays or maps and both encoders must be of the same type, i.e. both encode to an array or both encode to a map. If the encoders are incompatible or produce elements that are not wrapped in an array or map each encoding attempt will fail with a Borer.Error.Unsupported exception.

Creates a new Encoder which emits the flat, concatenated encoding of the underlying encoder and the given other one. Only works with encoders that encode to arrays or maps and both encoders must be of the same type, i.e. both encode to an array or both encode to a map. If the encoders are incompatible or produce elements that are not wrapped in an array or map each encoding attempt will fail with a Borer.Error.Unsupported exception.

Value parameters:
maxBufferSize

the maximum size of the buffer for the encoding of the first encoder

Wraps an Encoder definition with lazy initialization.

Wraps an Encoder definition with lazy initialization.

Implicits

Implicits

implicit def forArray[T : Encoder]: Encoder[Array[T]]
implicit val forBigDecimal: Encoder[BigDecimal]
implicit val forBigInt: Encoder[BigInt]
implicit val forBoolean: Encoder[Boolean]
implicit def forBoxedBoolean: Encoder[Boolean]
implicit def forBoxedByte: Encoder[Byte]
implicit def forBoxedChar: Encoder[Character]
implicit def forBoxedDouble: Encoder[Double]
implicit def forBoxedFloat: Encoder[Float]
implicit def forBoxedInt: Encoder[Integer]
implicit def forBoxedLong: Encoder[Long]
implicit def forBoxedShort: Encoder[Short]
implicit val forByte: Encoder[Byte]
implicit val forByteArrayDefault: Encoder[Array[Byte]]
implicit val forByteArrayIterator: Encoder[Iterator[Array[Byte]]]
implicit def forBytesIterator[Bytes : ByteAccess]: Encoder[Iterator[Bytes]]
implicit val forChar: Encoder[Char]
implicit val forDouble: Encoder[Double]
implicit val forFloat: Encoder[Float]
implicit def forIndexedSeq[T : Encoder, M <: (IndexedSeq)]: DefaultValueAware[M[T]]
implicit val forInt: Encoder[Int]
implicit val forJBigDecimal: Encoder[BigDecimal]
implicit val forJBigInteger: Encoder[BigInteger]
implicit def forLinearSeq[T : Encoder, M <: (LinearSeq)]: DefaultValueAware[M[T]]
implicit val forLong: Encoder[Long]
implicit def forMap[A : Encoder, B : Encoder, M <: (Map)]: DefaultValueAware[M[A, B]]
implicit val forNull: Encoder[Null]
implicit def forOption[T : Encoder]: DefaultValueAware[Option[T]]
implicit val forShort: Encoder[Short]
implicit val forString: Encoder[String]
implicit val forStringIterator: Encoder[Iterator[String]]
implicit inline def forTuple[T <: Tuple : ProductOf]: Encoder[T]
implicit val forUnit: Encoder[Unit]
implicit def fromCodec[T](implicit codec: Codec[T]): Encoder[T]

Inherited implicits

final implicit def forIterableOnce[T : Encoder, M <: (IterableOnce)]: Encoder[M[T]]
Inherited from:
LowPrioEncoders
final implicit def forIterator[T : Encoder]: Encoder[Iterator[T]]
Inherited from:
LowPrioEncoders