Binds the discriminator value D
to type Y
.
(discriminated: StringAdd).self
(discriminated: StringFormat).self
(discriminated: ArrowAssoc[Discriminated[X, D]]).x
(Since version 2.10.0) Use leftOfArrow
instead
(discriminated: Ensuring[Discriminated[X, D]]).x
(Since version 2.10.0) Use resultOfEnsuring
instead
Wrapper class that indicates subtypes of
X
are discriminated by typeD
using the suppliedCodec[D]
.For example, an implicit
Discriminated
value can be defined in the companion of a sealed trait, along with implicitDiscriminator
values in each subtype companion. Given such implicits, a codec for the trait can be automatically derived usingCodec[X]
.Contains an optional codec transformation, which is applied to every component codec before encoding/decoding. This allows common structure, e.g., size based framing, to be specified in one location.
For example, if each discriminated subtype is prefixed by a size field, the framing could be specified as:
type that can be discriminated by discriminator values of type
D
value type that discriminates
Y
in context ofX
from other types using discriminators ofD
for some typeY