MapBasedCodecs

io.bullet.borer.derivation.MapBasedCodecs
object MapBasedCodecs extends DerivationApi

Derivation macros for array-based encodings.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

abstract class MapBasedAdtDecoder[T] extends DerivedAdtDecoder[T]

Attributes

Supertypes
trait AdtDecoder[T]
trait Decoder[T]
class Object
trait Matchable
class Any
Show all
abstract class MapBasedAdtEncoder[T](strategy: AdtEncodingStrategy) extends DerivedAdtEncoder[T]

Attributes

Supertypes
trait AdtEncoder[T]
trait Encoder[T]
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

inline def deriveAllCodecs[T]: Codec[T]

Macro that creates an Encoder and Decoder pair for T and all direct and indirect sub-types of T. Convenience shortcut for Codec(deriveAllEncoders[T], deriveAllDecoders[T]).

Macro that creates an Encoder and Decoder pair for T and all direct and indirect sub-types of T. Convenience shortcut for Codec(deriveAllEncoders[T], deriveAllDecoders[T]).

Attributes

inline def deriveAllDecoders[T]: Decoder[T]

Macro that creates a Decoder for T and all direct and indirect sub-types of T, which are concrete, i.e. not abstract. T must be an enum, sealed abstract class or sealed trait.

Macro that creates a Decoder for T and all direct and indirect sub-types of T, which are concrete, i.e. not abstract. T must be an enum, sealed abstract class or sealed trait.

It works by generating a code block such as this one:

 implicit val a = deriveDecoder[A]     // one such line is generated for each concrete
 implicit val b = deriveDecoder[B]     // direct or indirect sub-type of T which doesn't
 implicit val c = deriveDecoder[C]     // already have an implicit Decoder available
 ...
 deriveDecoder[T]

If a Decoder for a certain concrete sub-type S <: T is already implicitly available at the macro call-site the respective line for the sub-type is not generated.

If a Decoder for a certain abstract sub-type S <: T is already implicitly available at the macro call-site the respective lines for all sub-types of S are not generated.

This means that you can specify your own custom Decoders for concrete sub-types or whole branches of the sub-type hierarchy and they will be properly picked up rather than create conflicts.

Attributes

inline def deriveAllEncoders[T]: Encoder[T]

Macro that creates an Encoder for T and all direct and indirect sub-types of T, which are concrete, i.e. not abstract. T must be an enum, sealed abstract class or sealed trait.

Macro that creates an Encoder for T and all direct and indirect sub-types of T, which are concrete, i.e. not abstract. T must be an enum, sealed abstract class or sealed trait.

It works by generating a code block such as this one:

 implicit val a = deriveEncoder[A]     // one such line is generated for each concrete
 implicit val b = deriveEncoder[B]     // direct or indirect sub-type of T which doesn't
 implicit val c = deriveEncoder[C]     // already have an implicit Encoder available
 ...
 deriveEncoder[T]

If an Encoder for a certain concrete sub-type S <: T is already implicitly available at the macro call-site the respective line for the sub-type is not generated.

If an Encoder for a certain abstract sub-type S <: T is already implicitly available at the macro call-site the respective lines for all sub-types of S are not generated.

This means that you can specify your own custom Encoders for concrete sub-types or whole branches of the sub-type hierarchy and they will be properly picked up rather than create conflicts.

Attributes

inline def deriveCodec[T]: Codec[T]

Macro that creates an Encoder and Decoder pair for T. Convenience shortcut for Codec(deriveEncoder[T], deriveDecoder[T]).

Macro that creates an Encoder and Decoder pair for T. Convenience shortcut for Codec(deriveEncoder[T], deriveDecoder[T]).

Attributes

inline def deriveDecoder[T]: Decoder[T]

Macro that creates a Decoder for T provided that

Macro that creates a Decoder for T provided that

  • T is a case class, enum, sealed abstract class or sealed trait
  • Decoder instances for all members of T (if T is a case class) or all sub-types of T (if T is an ADT) are implicitly available

Case classes are created from a map of values, one key-value pair for each member. The key for each member is a String holding the member's name. This can be customized with the key annotation.

Attributes

inline def deriveEncoder[T]: Encoder[T]

Macro that creates an Encoder for T provided that

Macro that creates an Encoder for T provided that

  • T is a case class, enum, sealed abstract class or sealed trait
  • Encoder instances for all members of T (if T is a case class) or all sub-types of T (if T is an ADT) are implicitly available

Case classes are converted into a map of values, one key-value pair for each member. The key for each member is a String holding the member's name. This can be customized with the key annotation.

Attributes

Extensions

Inherited extensions

extension (c: Encoder.type)
inline def derived[A]: Encoder[A]

This enables Encoder derivation via the derives clauses, e.g.

This enables Encoder derivation via the derives clauses, e.g.

import io.bullet.borer.derivation.MapBasedCodecs.*

case class Foo(x: Int) derives Encoder

Attributes

Inherited from:
DerivationApi
extension (c: Decoder.type)
inline def derived[A]: Decoder[A]

This enables Decoder derivation via the derives clauses, e.g.

This enables Decoder derivation via the derives clauses, e.g.

import io.bullet.borer.derivation.MapBasedCodecs.*

case class Foo(x: Int) derives Decoder

Attributes

Inherited from:
DerivationApi
extension (c: Codec.type)
inline def derived[A]: Codec[A]

This enables Codec derivation via the derives clauses, e.g.

This enables Codec derivation via the derives clauses, e.g.

import io.bullet.borer.derivation.MapBasedCodecs.*

case class Foo(x: Int) derives Codec

Attributes

Inherited from:
DerivationApi
extension (c: All.type)
inline def derived[A]: All[A]

This enables Encoder derivation via the derives clause, e.g.

This enables Encoder derivation via the derives clause, e.g.

import io.bullet.borer.derivation.MapBasedCodecs.*

enum Bar derives Encoder.All:
  ...

Attributes

Inherited from:
DerivationApi
extension (c: All.type)
inline def derived[A]: All[A]

This enables Decoder derivation via the derives clause, e.g.

This enables Decoder derivation via the derives clause, e.g.

import io.bullet.borer.derivation.MapBasedCodecs.*

enum Bar derives Decoder.All:
  ...

Attributes

Inherited from:
DerivationApi
extension (c: All.type)
inline def derived[A]: All[A]

This enables Codec derivation via the derives clause, e.g.

This enables Codec derivation via the derives clause, e.g.

import io.bullet.borer.derivation.MapBasedCodecs.*

enum Bar derives Codec.All:
 ...

Attributes

Inherited from:
DerivationApi