scodec.codecs

DiscriminatorCodec

final class DiscriminatorCodec[A, B] extends Codec[A]

Codec that supports the binary structure tag ++ value where the tag identifies the encoding/decoding of the value.

To build an instance of this codec, call discriminated and specify the tag type via the by method. Then call one more more of the case combinators on this class.

Each of the case combinators provides two forms, one that defines a case with a single tag value and another, overloaded form that defines a case with a tag value to use in encoding and a predicate on tag value to use in decoding.

The most general case combinators are caseO and caseP (and their operator equivalents, ? and |). In addition to a tag or tag/predicate pair, the caseO combinators are defined by providing a mapping from A to Option[R], a mapping from R to A, and a Codec[R]. The case is used for encoding if the mapping from A to Option[R] returns a Some and it is used for decoding upon matching the tag value. The caseP combinators work the same but take a PartialFunction[A, R] instead of an A => Option[R].

If R is a subtype of A, then the mapping from R to A can be omitted. Hence, the subcaseO and subcaseP (and the operator equivalents, / and \) constrain R to being a subtype of A and do not take a R => A function.

Finally, the least generic case combinators are the typecase combinators which add further constraints to the subcase* combinators. Specifically, the typecase operators omit the A => Option[R] or PartialFunction[A, R] in favor of doing subtype checks. For example, the following codec is a Codec[AnyVal] that encodes a 0 if passed a Boolean and a 1 if passed an Int:

discriminated[AnyVal].by(uint8).typecase(0, bool).typecase(1, int32)
Source
DiscriminatorCodec.scala
See also

discriminated

Linear Supertypes
Codec[A], GenCodec[A, A], Decoder[A], Encoder[A], AnyRef, Any
Type Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Grouped
  2. Alphabetic
  3. By inheritance
Inherited
  1. DiscriminatorCodec
  2. Codec
  3. GenCodec
  4. Decoder
  5. Encoder
  6. AnyRef
  7. Any
Implicitly
  1. by ValueCodecEnrichedWithHListSupport
  2. by HListCodecEnrichedWithHListSupport
  3. by ValueEnrichedWithTuplingSupport
  4. by any2stringadd
  5. by StringFormat
  6. by Ensuring
  7. by ArrowAssoc
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to any2stringadd[DiscriminatorCodec[A, B]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (DiscriminatorCodec[A, B], B)

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to ArrowAssoc[DiscriminatorCodec[A, B]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. def /[R <: A](encodeTag: B, decodeTag: (B) ⇒ Boolean)(toRep: (A) ⇒ Option[R])(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag. Operator alias for subcaseO.

    R

    representative type that this case handles

    encodeTag

    tag value to use during encoding for this case

    decodeTag

    function that determines if this case should be used for decoding given a decoded tag

    toRep

    function used during encoding that converts an A to an Option[R]

    cr

    codec that encodes/decodes Rs

  6. def /[R <: A](tag: B)(toRep: (A) ⇒ Option[R])(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag. Operator alias for subcaseO.

    R

    representative type that this case handles

    tag

    tag value for this case

    toRep

    function used during encoding that converts an A to an Option[R]

    cr

    codec that encodes/decodes Rs

  7. def :+[B, LB <: HList](codec: Codec[B])(implicit prepend: shapeless.ops.hlist.Prepend.Aux[A, ::[B, HNil], LB], init: Aux[LB, A], last: Aux[LB, B]): Codec[LB]

    When called on a Codec[L] for some L <: HList, returns a new codec that encodes/decodes the HList L followed by a B.

    When called on a Codec[L] for some L <: HList, returns a new codec that encodes/decodes the HList L followed by a B. That is, this operator is a codec-level HList append operation.

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to HListCodecEnrichedWithHListSupport[A] performed by method HListCodecEnrichedWithHListSupport in scodec. This conversion will take place only if A is a subclass of HList (A <: HList).
    Definition Classes
    HListCodecEnrichedWithHListSupport
  8. def ::[B](codecB: Codec[B]): Codec[::[B, ::[A, HNil]]]

    When called on a Codec[A] where A is not a subytpe of HList, creates a new codec that encodes/decodes an HList of B :: A :: HNil.

    When called on a Codec[A] where A is not a subytpe of HList, creates a new codec that encodes/decodes an HList of B :: A :: HNil. For example,

    uint8 :: utf8

    has type Codec[Int :: String :: HNil]. uint8 :: utf8 }}}

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to ValueCodecEnrichedWithHListSupport[A] performed by method ValueCodecEnrichedWithHListSupport in scodec.
    Definition Classes
    ValueCodecEnrichedWithHListSupport
  9. def ::[B](codec: Codec[B]): Codec[::[B, A]]

    When called on a Codec[L] for some L <: HList, returns a new codec representing Codec[B :: L].

    When called on a Codec[L] for some L <: HList, returns a new codec representing Codec[B :: L]. That is, this operator is a codec-level HList prepend operation.

    codec

    codec to prepend

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to HListCodecEnrichedWithHListSupport[A] performed by method HListCodecEnrichedWithHListSupport in scodec. This conversion will take place only if A is a subclass of HList (A <: HList).
    Definition Classes
    HListCodecEnrichedWithHListSupport
  10. def :::[K <: HList, KL <: HList, KLen <: Nat](k: Codec[K])(implicit prepend: shapeless.ops.hlist.Prepend.Aux[K, A, KL], lengthK: Aux[K, KLen], split: Aux[KL, KLen, (K, A)]): Codec[KL]

    When called on a Codec[L] for some L <: HList, returns a new codec the encodes/decodes the HList K followed by the HList L.

    When called on a Codec[L] for some L <: HList, returns a new codec the encodes/decodes the HList K followed by the HList L.

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to HListCodecEnrichedWithHListSupport[A] performed by method HListCodecEnrichedWithHListSupport in scodec. This conversion will take place only if A is a subclass of HList (A <: HList).
    Definition Classes
    HListCodecEnrichedWithHListSupport
  11. def :~>:[B](codec: Codec[B])(implicit arg0: Monoid[B]): Codec[A]

    When called on a Codec[L] for some L <: HList, returns a new codec that encodes/decodes B :: L but only returns L.

    When called on a Codec[L] for some L <: HList, returns a new codec that encodes/decodes B :: L but only returns L. HList equivalent of ~>.

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to HListCodecEnrichedWithHListSupport[A] performed by method HListCodecEnrichedWithHListSupport in scodec. This conversion will take place only if A is a subclass of HList (A <: HList).
    Definition Classes
    HListCodecEnrichedWithHListSupport
  12. final def <~[B](codecB: Codec[B])(implicit arg0: Monoid[B]): Codec[A]

    Creates a Codec[A] that: encodes an A followed by the zero element of the Monoid of B; decodes an A followed by a B and discards the decoded B.

    Creates a Codec[A] that: encodes an A followed by the zero element of the Monoid of B; decodes an A followed by a B and discards the decoded B.

    Operator alias of dropRight.

    Definition Classes
    Codec
  13. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  14. def >>:~[L <: HList](f: (A) ⇒ Codec[L]): Codec[::[A, L]]

    Creates a new codec that encodes/decodes an HList type of A :: L given a function A => Codec[L].

    Creates a new codec that encodes/decodes an HList type of A :: L given a function A => Codec[L]. This allows later parts of an HList codec to be dependent on earlier values. Operator alias for flatPrepend.

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to ValueCodecEnrichedWithHListSupport[A] performed by method ValueCodecEnrichedWithHListSupport in scodec.
    Definition Classes
    ValueCodecEnrichedWithHListSupport
  15. final def >>~[B](f: (A) ⇒ Codec[B]): Codec[(A, B)]

    Returns a new codec that encodes/decodes a value of type (A, B) where the codec of B is dependent on A.

    Returns a new codec that encodes/decodes a value of type (A, B) where the codec of B is dependent on A. Operator alias for flatZip.

    Definition Classes
    Codec
  16. def ?[R](encodeTag: B, decodeTag: (B) ⇒ Boolean)(toRep: (A) ⇒ Option[R])(fromRep: (R) ⇒ A)(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag. Operator alias for caseO.

    R

    representative type that this case handles

    encodeTag

    tag value to use during encoding for this case

    decodeTag

    function that determines if this case should be used for decoding given a decoded tag

    toRep

    function used during encoding that converts an A to an Option[R]

    fromRep

    function used during decoding that converts an R to an A

    cr

    codec that encodes/decodes Rs

  17. def ?[R](tag: B)(toRep: (A) ⇒ Option[R])(fromRep: (R) ⇒ A)(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag. Operator alias for caseO.

    R

    representative type that this case handles

    tag

    tag value for this case

    toRep

    function used during encoding that converts an A to an Option[R]

    fromRep

    function used during decoding that converts an R to an A

    cr

    codec that encodes/decodes Rs

  18. def \[R <: A](encodeTag: B, decodeTag: (B) ⇒ Boolean)(toRep: PartialFunction[A, R])(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag. Operator alias for subcaseP.

    R

    representative type that this case handles

    encodeTag

    tag value to use during encoding for this case

    decodeTag

    function that determines if this case should be used for decoding given a decoded tag

    toRep

    partial function from A to R used during encoding

    cr

    codec that encodes/decodes Rs

  19. def \[R <: A](tag: B)(toRep: PartialFunction[A, R])(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag. Operator alias for subcaseP.

    R

    representative type that this case handles

    tag

    tag value for this case

    toRep

    partial function from A to R used during encoding

    cr

    codec that encodes/decodes Rs

  20. val a: DiscriminatorCodec[A, B]

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to ValueEnrichedWithTuplingSupport[DiscriminatorCodec[A, B]] performed by method ValueEnrichedWithTuplingSupport in scodec.codecs.
    Definition Classes
    ValueEnrichedWithTuplingSupport
  21. final def as[B](implicit as: CodecAsAux[B, A]): Codec[B]

    Returns a new codec that encodes/decodes a value of type B by using an iso between A and B.

    Returns a new codec that encodes/decodes a value of type B by using an iso between A and B.

    Definition Classes
    Codec
  22. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  23. def caseO[R](encodeTag: B, decodeTag: (B) ⇒ Boolean)(toRep: (A) ⇒ Option[R])(fromRep: (R) ⇒ A)(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag.

    R

    representative type that this case handles

    encodeTag

    tag value to use during encoding for this case

    decodeTag

    function that determines if this case should be used for decoding given a decoded tag

    toRep

    function used during encoding that converts an A to an Option[R]

    fromRep

    function used during decoding that converts an R to an A

    cr

    codec that encodes/decodes Rs

  24. def caseO[R](tag: B)(toRep: (A) ⇒ Option[R])(fromRep: (R) ⇒ A)(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag.

    R

    representative type that this case handles

    tag

    tag value for this case

    toRep

    function used during encoding that converts an A to an Option[R]

    fromRep

    function used during decoding that converts an R to an A

    cr

    codec that encodes/decodes Rs

  25. def caseP[R](encodeTag: B, decodeTag: (B) ⇒ Boolean)(toRep: PartialFunction[A, R])(fromRep: (R) ⇒ A)(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag.

    R

    representative type that this case handles

    encodeTag

    tag value to use during encoding for this case

    decodeTag

    function that determines if this case should be used for decoding given a decoded tag

    toRep

    partial function from A to R used during encoding

    fromRep

    function used during decoding that converts an R to an A

    cr

    codec that encodes/decodes Rs

  26. def caseP[R](tag: B)(toRep: PartialFunction[A, R])(fromRep: (R) ⇒ A)(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag.

    R

    representative type that this case handles

    tag

    tag value for this case

    toRep

    partial function from A to R used during encoding

    fromRep

    function used during decoding that converts an R to an A

    cr

    codec that encodes/decodes Rs

  27. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def compact: Codec[A]

    Converts this codec to a new codec that compacts the encoded bit vector before returning it.

    Converts this codec to a new codec that compacts the encoded bit vector before returning it.

    Definition Classes
    CodecGenCodecEncoder
  29. final def complete: Codec[A]

    Converts this codec to a new codec that fails decoding if there are remaining bits.

    Converts this codec to a new codec that fails decoding if there are remaining bits.

    Definition Classes
    CodecGenCodecDecoder
  30. def contramap[C](f: (C) ⇒ A): GenCodec[C, A]

    Converts this GenCodec to a GenCodec[C, B] using the supplied C => A.

    Converts this GenCodec to a GenCodec[C, B] using the supplied C => A.

    Definition Classes
    GenCodecEncoder
  31. def decode(bits: BitVector): \/[String, (BitVector, A)]

    Attempts to decode a value of type A from the specified bit vector.

    Attempts to decode a value of type A from the specified bit vector.

    bits

    bits to decode

    returns

    error if value could not be decoded or the remaining bits and the decoded value

    Definition Classes
    DiscriminatorCodecDecoder
  32. final def decodeValidValue(bits: BitVector): A

    Decodes a value of type A from the specified bit vector and discards any remaining bits, throwing an IllegalArgumentException if an error occurs.

    Decodes a value of type A from the specified bit vector and discards any remaining bits, throwing an IllegalArgumentException if an error occurs.

    bits

    bits to decode

    returns

    the decoded value

    Definition Classes
    Decoder
    Exceptions thrown
    IllegalArgumentException

    if a decoding error occurs

  33. final def decodeValue(bits: BitVector): \/[String, A]

    Attempts to decode a value of type A from the specified bit vector and discards any remaining bits.

    Attempts to decode a value of type A from the specified bit vector and discards any remaining bits.

    bits

    bits to decode

    returns

    error if value could not be decoded or the decoded value

    Definition Classes
    Decoder
  34. final def dropLeft[B](codecB: Codec[B])(implicit ma: Monoid[A]): Codec[B]

    Creates a Codec[B] that: encodes the zero element of the Monoid of A followed by a B; decodes an A followed by a B and discards the decoded A.

    Creates a Codec[B] that: encodes the zero element of the Monoid of A followed by a B; decodes an A followed by a B and discards the decoded A.

    Definition Classes
    Codec
  35. final def dropRight[B](codecB: Codec[B])(implicit arg0: Monoid[B]): Codec[A]

    Creates a Codec[A] that: encodes an A followed by the zero element of the Monoid of B; decodes an A followed by a B and discards the decoded B.

    Creates a Codec[A] that: encodes an A followed by the zero element of the Monoid of B; decodes an A followed by a B and discards the decoded B.

    Definition Classes
    Codec
  36. def encode(a: A): \/[String, BitVector]

    Attempts to encode the specified value in to a bit vector.

    Attempts to encode the specified value in to a bit vector.

    Definition Classes
    DiscriminatorCodecEncoder
  37. final def encodeValid(value: A): BitVector

    Encodes the specified value in to a bit vector, throwing an IllegalArgumentException if encoding fails.

    Encodes the specified value in to a bit vector, throwing an IllegalArgumentException if encoding fails.

    value

    value to encode

    Definition Classes
    Encoder
    Exceptions thrown
    IllegalArgumentException

    upon encoding failure

  38. def ensuring(cond: (DiscriminatorCodec[A, B]) ⇒ Boolean, msg: ⇒ Any): DiscriminatorCodec[A, B]

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to Ensuring[DiscriminatorCodec[A, B]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  39. def ensuring(cond: (DiscriminatorCodec[A, B]) ⇒ Boolean): DiscriminatorCodec[A, B]

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to Ensuring[DiscriminatorCodec[A, B]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  40. def ensuring(cond: Boolean, msg: ⇒ Any): DiscriminatorCodec[A, B]

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to Ensuring[DiscriminatorCodec[A, B]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  41. def ensuring(cond: Boolean): DiscriminatorCodec[A, B]

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to Ensuring[DiscriminatorCodec[A, B]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  42. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  43. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  44. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  45. def flatMap[B](f: (A) ⇒ Decoder[B]): Decoder[B]

    Converts this decoder to a Decoder[B] using the supplied A => Decoder[B].

    Converts this decoder to a Decoder[B] using the supplied A => Decoder[B].

    Definition Classes
    Decoder
  46. def flatPrepend[L <: HList](f: (A) ⇒ Codec[L]): Codec[::[A, L]]

    Creates a new codec that encodes/decodes an HList type of A :: L given a function A => Codec[L].

    Creates a new codec that encodes/decodes an HList type of A :: L given a function A => Codec[L]. This allows later parts of an HList codec to be dependent on earlier values.

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to ValueCodecEnrichedWithHListSupport[A] performed by method ValueCodecEnrichedWithHListSupport in scodec.
    Definition Classes
    ValueCodecEnrichedWithHListSupport
  47. final def flatZip[B](f: (A) ⇒ Codec[B]): Codec[(A, B)]

    Returns a new codec that encodes/decodes a value of type (A, B) where the codec of B is dependent on A.

    Returns a new codec that encodes/decodes a value of type (A, B) where the codec of B is dependent on A.

    Definition Classes
    Codec
  48. def flatZipHList[B](f: (A) ⇒ Codec[B]): Codec[::[A, ::[B, HNil]]]

    Creates a new codec that encodes/decodes an HList type of A :: B :: HNil given a function A => Codec[B].

    Creates a new codec that encodes/decodes an HList type of A :: B :: HNil given a function A => Codec[B]. If B is an HList type, consider using flatPrepend instead, which avoids nested HLists. This is the direct HList equivalent of flatZip.

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to ValueCodecEnrichedWithHListSupport[A] performed by method ValueCodecEnrichedWithHListSupport in scodec.
    Definition Classes
    ValueCodecEnrichedWithHListSupport
  49. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to StringFormat[DiscriminatorCodec[A, B]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  50. final def fuse[AA <: A, BB >: A](implicit ev: =:=[BB, AA]): Codec[BB]

    Converts this generalized codec in to a non-generalized codec assuming A and B are the same type.

    Converts this generalized codec in to a non-generalized codec assuming A and B are the same type.

    Definition Classes
    GenCodec
  51. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  52. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  53. final def hlist: Codec[::[A, HNil]]

    Lifts this codec in to a codec of a singleton hlist, which allows easy binding to case classes of one argument.

    Lifts this codec in to a codec of a singleton hlist, which allows easy binding to case classes of one argument.

    Definition Classes
    Codec
  54. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  55. def map[C](f: (A) ⇒ C): GenCodec[A, C]

    Converts this GenCodec to a GenCodec[A, C] using the supplied B => C.

    Converts this GenCodec to a GenCodec[A, C] using the supplied B => C.

    Definition Classes
    GenCodecDecoder
  56. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  57. final def notify(): Unit

    Definition Classes
    AnyRef
  58. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  59. final def pairedWith[B](codecB: Codec[B]): Codec[(A, B)]

    Creates a Codec[(A, B)] that first encodes/decodes an A followed by a B.

    Creates a Codec[(A, B)] that first encodes/decodes an A followed by a B.

    Definition Classes
    Codec
  60. def pcontramap[B](f: (B) ⇒ Option[A]): Encoder[B]

    Converts this encoder to an Encoder[B] using the supplied partial function from B to A.

    Converts this encoder to an Encoder[B] using the supplied partial function from B to A. The encoding will fail for any B that f maps to None.

    Definition Classes
    Encoder
  61. final def pxmap[B](f: (A) ⇒ B, g: (B) ⇒ Option[A]): Codec[B]

    Maps to a codec of type B, where there is a partial function from B to A.

    Maps to a codec of type B, where there is a partial function from B to A. The encoding will fail for any B that f maps to None.

    Definition Classes
    Codec
  62. def subcaseO[R <: A](encodeTag: B, decodeTag: (B) ⇒ Boolean)(toRep: (A) ⇒ Option[R])(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag.

    R

    representative type that this case handles

    encodeTag

    tag value to use during encoding for this case

    decodeTag

    function that determines if this case should be used for decoding given a decoded tag

    toRep

    function used during encoding that converts an A to an Option[R]

    cr

    codec that encodes/decodes Rs

  63. def subcaseO[R <: A](tag: B)(toRep: (A) ⇒ Option[R])(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag.

    R

    representative type that this case handles

    tag

    tag value for this case

    toRep

    function used during encoding that converts an A to an Option[R]

    cr

    codec that encodes/decodes Rs

  64. def subcaseP[R <: A](encodeTag: B, decodeTag: (B) ⇒ Boolean)(toRep: PartialFunction[A, R])(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag.

    R

    representative type that this case handles

    encodeTag

    tag value to use during encoding for this case

    decodeTag

    function that determines if this case should be used for decoding given a decoded tag

    toRep

    partial function from A to R used during encoding

    cr

    codec that encodes/decodes Rs

  65. def subcaseP[R <: A](tag: B)(toRep: PartialFunction[A, R])(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag.

    R

    representative type that this case handles

    tag

    tag value for this case

    toRep

    partial function from A to R used during encoding

    cr

    codec that encodes/decodes Rs

  66. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  67. def toString(): String

    Definition Classes
    DiscriminatorCodec → AnyRef → Any
  68. def typecase[R <: A](encodeTag: B, decodeTag: (B) ⇒ Boolean, cr: Codec[R])(implicit arg0: Manifest[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag.

    R

    representative type that this case handles

    encodeTag

    tag value to use during encoding for this case

    decodeTag

    function that determines if this case should be used for decoding given a decoded tag

    cr

    codec that encodes/decodes Rs

  69. def typecase[R <: A](tag: B, cr: Codec[R])(implicit arg0: Manifest[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag.

    R

    representative type that this case handles

    tag

    tag value for this case

    cr

    codec that encodes/decodes Rs

  70. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  71. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  72. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  73. final def withToString(str: String): Codec[A]

    Creates a new codec that is functionally equivalent to this codec but returns the specified string from toString.

    Creates a new codec that is functionally equivalent to this codec but returns the specified string from toString.

    Definition Classes
    Codec
  74. final def xmap[B](f: (A) ⇒ B, g: (B) ⇒ A): Codec[B]

    Maps to a codec of type B using two total functions, A => B and B => A.

    Maps to a codec of type B using two total functions, A => B and B => A.

    Definition Classes
    Codec
  75. def |[R](encodeTag: B, decodeTag: (B) ⇒ Boolean)(toRep: PartialFunction[A, R])(fromRep: (R) ⇒ A)(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag. Operator alias for caseP.

    R

    representative type that this case handles

    encodeTag

    tag value to use during encoding for this case

    decodeTag

    function that determines if this case should be used for decoding given a decoded tag

    toRep

    partial function from A to R used during encoding

    fromRep

    function used during decoding that converts an R to an A

    cr

    codec that encodes/decodes Rs

  76. def |[R](tag: B)(toRep: PartialFunction[A, R])(fromRep: (R) ⇒ A)(cr: Codec[R]): DiscriminatorCodec[A, B]

    Returns a new discriminator codec with a new case added for the specified tag.

    Returns a new discriminator codec with a new case added for the specified tag. Operator alias for caseP.

    R

    representative type that this case handles

    tag

    tag value for this case

    toRep

    partial function from A to R used during encoding

    fromRep

    function used during decoding that converts an R to an A

    cr

    codec that encodes/decodes Rs

  77. final def ~[B](codecB: Codec[B]): Codec[(A, B)]

    Creates a Codec[(A, B)] that first encodes/decodes an A followed by a B.

    Creates a Codec[(A, B)] that first encodes/decodes an A followed by a B.

    Operator alias for pairedWith.

    Definition Classes
    Codec
  78. final def ~>[B](codecB: Codec[B])(implicit ma: Monoid[A]): Codec[B]

    Creates a Codec[B] that: encodes the zero element of the Monoid of A followed by a B; decodes an A followed by a B and discards the decoded A.

    Creates a Codec[B] that: encodes the zero element of the Monoid of A followed by a B; decodes an A followed by a B and discards the decoded A.

    Operator alias of dropLeft.

    Definition Classes
    Codec
  79. def [B](y: B): (DiscriminatorCodec[A, B], B)

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to ArrowAssoc[DiscriminatorCodec[A, B]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Shadowed Implicit Value Members

  1. val self: Codec[A]

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to ValueCodecEnrichedWithHListSupport[A] performed by method ValueCodecEnrichedWithHListSupport in scodec.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (discriminatorCodec: ValueCodecEnrichedWithHListSupport[A]).self
    Definition Classes
    ValueCodecEnrichedWithHListSupport
  2. val self: Codec[A]

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to HListCodecEnrichedWithHListSupport[A] performed by method HListCodecEnrichedWithHListSupport in scodec. This conversion will take place only if A is a subclass of HList (A <: HList).
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (discriminatorCodec: HListCodecEnrichedWithHListSupport[A]).self
    Definition Classes
    HListCodecEnrichedWithHListSupport
  3. def ~[B](b: B): (DiscriminatorCodec[A, B], B)

    Implicit information
    This member is added by an implicit conversion from DiscriminatorCodec[A, B] to ValueEnrichedWithTuplingSupport[DiscriminatorCodec[A, B]] performed by method ValueEnrichedWithTuplingSupport in scodec.codecs.
    Shadowing
    This implicitly inherited member is shadowed by one or more members in this class.
    To access this member you can use a type ascription:
    (discriminatorCodec: ValueEnrichedWithTuplingSupport[DiscriminatorCodec[A, B]]).~(b)
    Definition Classes
    ValueEnrichedWithTuplingSupport

Inherited from Codec[A]

Inherited from GenCodec[A, A]

Inherited from Decoder[A]

Inherited from Encoder[A]

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion ValueCodecEnrichedWithHListSupport from DiscriminatorCodec[A, B] to ValueCodecEnrichedWithHListSupport[A]

Inherited by implicit conversion HListCodecEnrichedWithHListSupport from DiscriminatorCodec[A, B] to HListCodecEnrichedWithHListSupport[A]

Inherited by implicit conversion ValueEnrichedWithTuplingSupport from DiscriminatorCodec[A, B] to ValueEnrichedWithTuplingSupport[DiscriminatorCodec[A, B]]

Inherited by implicit conversion any2stringadd from DiscriminatorCodec[A, B] to any2stringadd[DiscriminatorCodec[A, B]]

Inherited by implicit conversion StringFormat from DiscriminatorCodec[A, B] to StringFormat[DiscriminatorCodec[A, B]]

Inherited by implicit conversion Ensuring from DiscriminatorCodec[A, B] to Ensuring[DiscriminatorCodec[A, B]]

Inherited by implicit conversion ArrowAssoc from DiscriminatorCodec[A, B] to ArrowAssoc[DiscriminatorCodec[A, B]]

Primary Members

Discriminator Support

Basic Combinators

Tuple Support

HList Support

Ungrouped