Convenience base class for GenCodec
s that serialize values as objects.
Convenience base class for GenCodec
s that serialize values as objects.
NOTE: if you need to implement a custom GenCodec
that writes an object, the best way to do it is to have
manually implemented apply
and unapply
in companion object or by using GenCodec.fromApplyUnapplyProvider.
Helper method to manually implement a GenCodec
that writes an object.
Helper method to manually implement a GenCodec
that writes an object. NOTE: in most cases the easiest way to
have a custom object codec is to manually implement apply
and unapply
/unapplySeq
methods in companion object
of your type or use fromApplyUnapplyProvider if the type comes from a third party code and you can't
modify its companion object.
Materializes a GenCodec for type T
using apply
and unapply
/unapplySeq
methods available on
passed applyUnapplyProvider
object.
Materializes a GenCodec for type T
using apply
and unapply
/unapplySeq
methods available on
passed applyUnapplyProvider
object. The signatures of apply
and unapply
must be as if T
was a case class
and applyUnapplyProvider
was its companion object.
This is useful for easy derivation of GenCodec for third party classes which don't have their own companion
objects with apply
and unapply
. So essentially the applyUnapplyProvider
is a "fake companion object"
of type T
.
Example:
class ThirdParty { ... } object ThirdPartyFakeCompanion { def apply(int: Int, string: String): ThirdParty = ... def unapply(tp: ThirdParty): Option[(Int, String)] = ... } implicit val thirdPartyCodec: GenCodec[ThirdParty] = GenCodec.fromApplyUnapplyProvider[ThirdParty](ThirdPartyFakeCompanion)
Macro that automatically materializes a GenCodec for some type T
, which must be one of:
Macro that automatically materializes a GenCodec for some type T
, which must be one of:
object
apply
and unapply
methods and every parameter type of apply
method has its own GenCodecNote that automatic materialization does NOT descend into types that T
is made of (e.g. types of case class
fields must have their own codecs independently declared). If you want recursive materialization, use
materializeRecursively
.
INTERNAL API.
INTERNAL API. Should not be used directly.
Like materialize
, but descends into types that T
is made of (e.g.
Like materialize
, but descends into types that T
is made of (e.g. case class field types).