Wrapper over GenCodec which forces fully automatic derivation.
Wrapper over GenCodec which forces fully automatic derivation.
If you ask for implicit value of type GenCodec[T], the codec must be explicitly declared and imported or
put into implicit scope (e.g. companion object of T), even though it can be automatically implemented
using materialize or materializeRecursively.
However, if you ask for implicit value of type GenCodec.Auto[T], the compiler will always fall back to fully
automatic derivation if it cannot find already declared GenCodec. Note that since GenCodec.Auto will always
try to wrap already existing GenCodec (if there is one), you should never explicitly declare any instances
of GenCodec.Auto. If you need custom serialization, just write a GenCodec and GenCodec.Auto will wrap it.
Whether you want to use GenCodec or GenCodec.Auto depends on your use case. GenCodec should be generally
used when you want the programmer to always explicitly state that some type is serializable. For example, if you
serialize your objects in order to put them into database, you probably want to use GenCodec and not GenCodec.Auto,
because every type that has been written to database is likely to be bound by backwards compatibility constraints and
cannot be freely refactored. That's why you want to always explicitly make the decision of making a type serializable.
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:
objectapply
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.
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).
Used internally for materialization of GenCodec.Auto.
Used internally for materialization of GenCodec.Auto. Should not be used directly.