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

io.circe.generic.extras.AutoDerivation.scala Maven / Gradle / Ivy

There is a newer version: 0.11.2
Show newest version
package io.circe.generic.extras

import io.circe.{ Decoder, ObjectEncoder }
import io.circe.export.Exported
import io.circe.generic.extras.decoding.ConfiguredDecoder
import io.circe.generic.extras.encoding.ConfiguredObjectEncoder
import io.circe.generic.util.macros.ExportMacros
import scala.language.experimental.macros

/**
 * Fully automatic configurable codec derivation.
 *
 * Extending this trait provides [[io.circe.Decoder]] and [[io.circe.Encoder]]
 * instances for case classes (if all members have instances), "incomplete" case classes, sealed
 * trait hierarchies, etc.
 */
trait AutoDerivation {
  implicit def exportDecoder[A]: Exported[Decoder[A]] =
    macro ExportMacros.exportDecoder[ConfiguredDecoder, A]
  implicit def exportEncoder[A]: Exported[ObjectEncoder[A]] =
    macro ExportMacros.exportEncoder[ConfiguredObjectEncoder, A]
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy