Packages

  • package root
    Definition Classes
    root
  • package scodec

    Combinator library for working with binary data.

    Combinator library for working with binary data.

    The primary abstraction of this library is Codec, which provides the ability to encode/decode values to/from binary.

    There are more general abstractions though, such as Encoder and Decoder. There's also GenCodec which extends both Encoder and Decoder but allows the types to vary. Given these more general abstractions, a Codec[A] can be represented as a GenCodec[A, A].

    The more general abstractions are important because they allow operations on codecs that would not otherwise be possible. For example, given a Codec[A], mapping a function A => B over the codec yields a GenCodec[A, B]. Without the more general abstractions, map is impossible to define (e.g., how would codec.map(f).encode(b) be implemented?). Given a GenCodec[A, B], the encoding functionality can be ignored by treating it as a Decoder[B], or the encoding type can be changed via contramap. If after further transformations, the two types to GenCodec are equal, we can reconstitute a Codec from the GenCodec by calling fuse.

    See the codecs package object for pre-defined codecs for many common data types and combinators for building larger codecs out of smaller ones.

    For the categorically minded, note the following:

    • Decoder is a monad
    • Encoder is a contravariant functor
    • GenCodec is a profunctor
    • Codec is an invariant functor
    Definition Classes
    root
  • package codecs

    Provides codecs for common types and combinators for building larger codecs.

    Provides codecs for common types and combinators for building larger codecs.

    Bits and Bytes Codecs

    The simplest of the provided codecs are those that encode/decode BitVectors and ByteVectors directly. These are provided by bits and bytes methods. These codecs encode all of the bits/bytes directly in to the result and decode *all* of the remaining bits/bytes in to the result value. That is, the result of decode always returns a empty bit vector for the remaining bits.

    Similarly, fixed size alternatives are provided by the bits(size) and bytes(size) methods, which encode a fixed number of bits/bytes (or error if not provided the correct size) and decoded a fixed number of bits/bytes (or error if that many bits/bytes are not available).

    There are more specialized codecs for working with bits, including ignore and constant.

    Numeric Codecs

    There are built-in codecs for Int, Long, Float, and Double.

    There are a number of predefined integral codecs named using the form:

    [u]int$${size}[L]

    where u stands for unsigned, size is replaced by one of 8, 16, 24, 32, 64, and L stands for little-endian. For each codec of that form, the type is Codec[Int] or Codec[Long] depending on the specified size. For example, int32 supports 32-bit big-endian 2s complement signed integers, and uint16L supports 16-bit little-endian unsigned integers. Note: uint64[L] are not provided because a 64-bit unsigned integer does not fit in to a Long.

    Additionally, methods of the form [u]int[L](size: Int) and [u]long[L](size: Int) exist to build arbitrarily sized codecs, within the limitations of Int and Long.

    IEEE 754 floating point values are supported by the float, floatL, double, and doubleL codecs.

    Miscellaneous Value Codecs

    In addition to the numeric codecs, there are built-in codecs for Boolean, String, and UUID.

    Boolean values are supported by the bool codecs.

    Combinators

    There are a number of methods provided that create codecs out of other codecs. These include simple combinators such as fixedSizeBits and variableSizeBits and advanced combinators such as discriminated, which provides its own DSL for building a large codec out of many small codecs. For a list of all combinators, see the Combinators section below.

    Cryptography Codecs

    There are codecs that support working with encrypted data (encrypted), digital signatures and checksums (fixedSizeSignature and variableSizeSignature). Additionally, support for java.security.cert.Certificates is provided by certificate and x509Certificate.

    Definition Classes
    scodec
  • ChecksumCodec
  • ChecksumFactory
  • ChecksumMismatch
  • CipherFactory
  • CoproductBuilderAuto
  • CoproductBuilderAutoDiscriminators
  • CoproductBuilderKeyDiscriminators
  • CoproductCodecBuilder
  • DeMultiplexer
  • DeriveHListElementAux
  • Discriminated
  • Discriminator
  • DiscriminatorCodec
  • DropUnits
  • DropUnitsLowPriority
  • FlattenLeftPairs
  • ImplicitCodecs
  • ImplicitCollections
  • ImplicitValues
  • InvertibleRemove
  • KnownDiscriminatorType
  • MultiplexedCodec
  • NeedDiscriminatorCodec
  • PaddedVarAlignedCodec
  • SignatureFactory
  • SignatureSigner
  • Signer
  • SignerFactory
  • StringEnrichedWithCodecContextSupport
  • ToCoproductCodecs
  • ToHListCodec
  • Tuple10Codec
  • Tuple11Codec
  • Tuple12Codec
  • Tuple3Codec
  • Tuple4Codec
  • Tuple5Codec
  • Tuple6Codec
  • Tuple7Codec
  • Tuple8Codec
  • Tuple9Codec
  • TupleCodec
  • ValueEnrichedWithTuplingSupport
  • VarIntCodec
  • VarLongCodec
  • implicits
  • literals
  • ~
c

scodec.codecs

Tuple5Codec

final class Tuple5Codec[A, B, C, D, E] extends Codec[(A, B, C, D, E)]

Source
TupleCodec.scala
Linear Supertypes
Codec[(A, B, C, D, E)], GenCodec[(A, B, C, D, E), (A, B, C, D, E)], Decoder[(A, B, C, D, E)], Encoder[(A, B, C, D, E)], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Tuple5Codec
  2. Codec
  3. GenCodec
  4. Decoder
  5. Encoder
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Tuple5Codec(A: Codec[A], B: Codec[B], C: Codec[C], D: Codec[D], E: Codec[E])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def :+:[B](left: Codec[B]): CoproductCodecBuilder[:+:[B, :+:[(A, B, C, D, E), CNil]], ::[Codec[B], ::[Codec[(A, B, C, D, E)], HNil]], :+:[B, :+:[(A, B, C, D, E), CNil]]]

    Supports creation of a coproduct codec.

    Supports creation of a coproduct codec. See scodec.codecs.CoproductCodecBuilder for details.

    Definition Classes
    Codec
  4. final def <~[B](codecB: Codec[B])(implicit ev: =:=[Unit, B]): Codec[(A, B, C, D, E)]

    Assuming B is Unit, creates a Codec[A] that: encodes the A followed by a unit; decodes an A followed by a unit and discards the decoded unit.

    Assuming B is Unit, creates a Codec[A] that: encodes the A followed by a unit; decodes an A followed by a unit and discards the decoded unit.

    Operator alias of dropRight.

    Definition Classes
    Codec
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final def >>~[B](f: ((A, B, C, D, E)) ⇒ Codec[B]): Codec[((A, B, C, D, E), 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
  7. def asDecoder: Decoder[(A, B, C, D, E)]

    Gets this as a Decoder.

    Gets this as a Decoder.

    Definition Classes
    Decoder
  8. def asEncoder: Encoder[(A, B, C, D, E)]

    Gets this as an Encoder.

    Gets this as an Encoder.

    Definition Classes
    Encoder
  9. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  10. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  11. final def compact: Codec[(A, B, C, D, E)]

    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
  12. final def complete: Codec[(A, B, C, D, E)]

    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
  13. final def consume[B](f: ((A, B, C, D, E)) ⇒ Codec[B])(g: (B) ⇒ (A, B, C, D, E)): Codec[B]

    Similar to flatZip except the A type is not visible in the resulting type -- the binary effects of the Codec[A] still occur though.

    Similar to flatZip except the A type is not visible in the resulting type -- the binary effects of the Codec[A] still occur though.

    Example usage:

    case class Flags(x: Boolean, y: Boolean, z: Boolean)
    (bool :: bool :: bool :: ignore(5)).consume { flgs =>
      conditional(flgs.x, uint8) :: conditional(flgs.y, uint8) :: conditional(flgs.z, uint8)
    } {
      case x :: y :: z :: HNil => Flags(x.isDefined, y.isDefined, z.isDefined) }
    }

    Note that when B is an HList, this method is equivalent to using flatPrepend and derive. That is, a.consume(f)(g) === a.flatPrepend(f).derive[A].from(g).

    Definition Classes
    Codec
  14. def contramap[C](f: (C) ⇒ (A, B, C, D, E)): GenCodec[C, (A, B, C, D, E)]

    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
  15. def decode(bits: BitVector): Attempt[DecodeResult[(A, B, C, D, E)]]

    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
    Tuple5CodecDecoder
  16. def decodeOnly[AA >: (A, B, C, D, E)]: Codec[AA]

    Converts this to a codec that fails encoding with an error.

    Converts this to a codec that fails encoding with an error.

    Definition Classes
    CodecDecoder
  17. final def decodeValue(bits: BitVector): Attempt[(A, B, C, D, E)]

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

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

    bits

    bits to decode

    returns

    error if value could not be decoded or the decoded value

    Definition Classes
    Decoder
  18. final def downcast[B <: (A, B, C, D, E)](implicit tb: Typeable[B]): Codec[B]

    Safely lifts this codec to a codec of a subtype.

    Safely lifts this codec to a codec of a subtype.

    When a supertype of B that is not a supertype of A is decoded, an decoding error is returned.

    Definition Classes
    Codec
  19. final def dropLeft[B](codecB: Codec[B])(implicit ev: =:=[Unit, (A, B, C, D, E)]): Codec[B]

    Assuming A is Unit, creates a Codec[B] that: encodes the unit followed by a B; decodes a unit followed by a B and discards the decoded unit.

    Assuming A is Unit, creates a Codec[B] that: encodes the unit followed by a B; decodes a unit followed by a B and discards the decoded unit.

    Definition Classes
    Codec
  20. final def dropRight[B](codecB: Codec[B])(implicit ev: =:=[Unit, B]): Codec[(A, B, C, D, E)]

    Assuming B is Unit, creates a Codec[A] that: encodes the A followed by a unit; decodes an A followed by a unit and discards the decoded unit.

    Assuming B is Unit, creates a Codec[A] that: encodes the A followed by a unit; decodes an A followed by a unit and discards the decoded unit.

    Definition Classes
    Codec
  21. def econtramap[C](f: (C) ⇒ Attempt[(A, B, C, D, E)]): GenCodec[C, (A, B, C, D, E)]

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

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

    Definition Classes
    GenCodecEncoder
  22. def emap[C](f: ((A, B, C, D, E)) ⇒ Attempt[C]): GenCodec[(A, B, C, D, E), C]

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

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

    Definition Classes
    GenCodecDecoder
  23. def encode(abcde: (A, B, C, D, E)): Attempt[BitVector]

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

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

    returns

    error or binary encoding of the value

    Definition Classes
    Tuple5CodecEncoder
  24. def encodeOnly: Codec[(A, B, C, D, E)]

    Converts this to a codec that fails decoding with an error.

    Converts this to a codec that fails decoding with an error.

    Definition Classes
    Encoder
  25. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  26. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  27. final def exmap[B](f: ((A, B, C, D, E)) ⇒ Attempt[B], g: (B) ⇒ Attempt[(A, B, C, D, E)]): Codec[B]

    Transforms using two functions, A => Attempt[B] and B => Attempt[A].

    Transforms using two functions, A => Attempt[B] and B => Attempt[A].

    Definition Classes
    Codec
  28. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  29. def flatMap[B](f: ((A, B, C, D, E)) ⇒ 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
  30. final def flatZip[B](f: ((A, B, C, D, E)) ⇒ Codec[B]): Codec[((A, B, C, D, E), 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
  31. final def flattenLeftPairs(implicit f: FlattenLeftPairs[(A, B, C, D, E)]): Codec[Out]

    Converts this codec to an HList based codec by flattening all left nested pairs.

    Converts this codec to an HList based codec by flattening all left nested pairs. For example, flattenLeftPairs on a Codec[(((A, B), C), D)] results in a Codec[A :: B :: C :: D :: HNil]. This is particularly useful when combined with ~, ~>, and <~.

    Definition Classes
    Codec
  32. final def fuse[AA <: (A, B, C, D, E), BB >: (A, B, C, D, E)](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
  33. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  34. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  35. final def hlist: Codec[::[(A, B, C, D, E), HNil]]

    Lifts this codec in to a codec of a singleton hlist.

    Lifts this codec in to a codec of a singleton hlist.

    Definition Classes
    Codec
  36. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  37. def map[C](f: ((A, B, C, D, E)) ⇒ C): GenCodec[(A, B, C, D, E), 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
  38. final def narrow[B](f: ((A, B, C, D, E)) ⇒ Attempt[B], g: (B) ⇒ (A, B, C, D, E)): Codec[B]

    Transforms using two functions, A => Attempt[B] and B => A.

    Transforms using two functions, A => Attempt[B] and B => A.

    The supplied functions form an injection from B to A. Hence, this method converts from a larger to a smaller type. Hence, the name narrow.

    Definition Classes
    Codec
  39. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  40. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  41. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  42. final def pairedWith[B](codecB: Codec[B]): Codec[((A, B, C, D, E), 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
  43. def pcontramap[C](f: (C) ⇒ Option[(A, B, C, D, E)]): GenCodec[C, (A, B, C, D, E)]

    Converts this GenCodec to a GenCodec[C, B] using the supplied partial function from C to A.

    Converts this GenCodec to a GenCodec[C, B] using the supplied partial function from C to A. The encoding will fail for any C that f maps to None.

    Definition Classes
    GenCodecEncoder
  44. def sizeBound: SizeBound

    Provides a bound on the size of successfully encoded values.

    Provides a bound on the size of successfully encoded values.

    Definition Classes
    Tuple5CodecEncoder
  45. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  46. def toField[K]: Codec[FieldType[K, (A, B, C, D, E)]]

    Lifts this codec to a codec of a shapeless field -- allowing it to be used in records and unions.

    Lifts this codec to a codec of a shapeless field -- allowing it to be used in records and unions.

    Definition Classes
    Codec
  47. def toFieldWithContext[K <: Symbol](k: K): Codec[FieldType[K, (A, B, C, D, E)]]

    Lifts this codec to a codec of a shapeless field -- allowing it to be used in records and unions.

    Lifts this codec to a codec of a shapeless field -- allowing it to be used in records and unions. The specified key is pushed in to the context of any errors that are returned from the resulting codec.

    Definition Classes
    Codec
  48. def toString(): String
    Definition Classes
    Tuple5Codec → AnyRef → Any
  49. final def tuple: Codec[::[(A, B, C, D, E), HNil]]

    Alias for .hlist - allows cross compilation with Scodec 2 / Scala 3.

    Alias for .hlist - allows cross compilation with Scodec 2 / Scala 3.

    Definition Classes
    Codec
  50. final def unit(zero: (A, B, C, D, E)): Codec[Unit]

    Converts this to a Codec[Unit] that encodes using the specified zero value and decodes a unit value when this codec decodes an A successfully.

    Converts this to a Codec[Unit] that encodes using the specified zero value and decodes a unit value when this codec decodes an A successfully.

    Definition Classes
    Codec
  51. final def upcast[B >: (A, B, C, D, E)](implicit ta: Typeable[(A, B, C, D, E)]): Codec[B]

    Safely lifts this codec to a codec of a supertype.

    Safely lifts this codec to a codec of a supertype.

    When a subtype of B that is not a subtype of A is passed to encode, an encoding error is returned.

    Definition Classes
    Codec
  52. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  53. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  54. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  55. final def widen[B](f: ((A, B, C, D, E)) ⇒ B, g: (B) ⇒ Attempt[(A, B, C, D, E)]): Codec[B]

    Transforms using two functions, A => B and B => Attempt[A].

    Transforms using two functions, A => B and B => Attempt[A].

    The supplied functions form an injection from A to B. Hence, this method converts from a smaller to a larger type. Hence, the name widen.

    Definition Classes
    Codec
  56. def widenAs[X](to: (A, B, C, D, E) ⇒ X, from: (X) ⇒ Option[(A, B, C, D, E)]): Codec[X]
  57. final def withContext(context: String): Codec[(A, B, C, D, E)]

    Creates a new codec that is functionally equivalent to this codec but pushes the specified context string in to any errors returned from encode or decode.

    Creates a new codec that is functionally equivalent to this codec but pushes the specified context string in to any errors returned from encode or decode.

    Definition Classes
    Codec
  58. final def withToString(str: ⇒ String): Codec[(A, B, C, D, E)]

    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
  59. final def xmap[B](f: ((A, B, C, D, E)) ⇒ B, g: (B) ⇒ (A, B, C, D, E)): Codec[B]

    Transforms using the isomorphism described by two functions, A => B and B => A.

    Transforms using the isomorphism described by two functions, A => B and B => A.

    Definition Classes
    Codec
  60. final def ~[B](codecB: Codec[B]): Codec[((A, B, C, D, E), 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
  61. final def ~>[B](codecB: Codec[B])(implicit ev: =:=[Unit, (A, B, C, D, E)]): Codec[B]

    Assuming A is Unit, creates a Codec[B] that: encodes the unit followed by a B; decodes a unit followed by a B and discards the decoded unit.

    Assuming A is Unit, creates a Codec[B] that: encodes the unit followed by a B; decodes a unit followed by a B and discards the decoded unit.

    Operator alias of dropLeft.

    Definition Classes
    Codec
  62. def ~~[F](F: Codec[F]): Tuple6Codec[A, B, C, D, E, F]

Inherited from Codec[(A, B, C, D, E)]

Inherited from GenCodec[(A, B, C, D, E), (A, B, C, D, E)]

Inherited from Decoder[(A, B, C, D, E)]

Inherited from Encoder[(A, B, C, D, E)]

Inherited from AnyRef

Inherited from Any

Primary Members

Basic Combinators

Tuple Support

HList Support

Coproduct Support

Ungrouped