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
  • Attempt
  • BuildInfo
  • Codec
  • CodecTransformation
  • DecodeResult
  • Decoder
  • DecoderFunctions
  • DecodingContext
  • Encoder
  • EncoderFunctions
  • EnrichedCoproductDecoder
  • EnrichedCoproductEncoder
  • EnrichedHList
  • Err
  • GenCodec
  • HListCodecEnrichedWithHListSupport
  • SizeBound
  • Transform
  • TransformSyntax
  • Transformer
  • Tuple2CodecSupport
  • ValueCodecEnrichedWithGenericSupport
  • ValueCodecEnrichedWithHListSupport
c

scodec

HListCodecEnrichedWithHListSupport

implicit final class HListCodecEnrichedWithHListSupport[L <: HList] extends AnyVal

Provides common operations on a Codec[HList].

Source
package.scala
Linear Supertypes
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. HListCodecEnrichedWithHListSupport
  2. AnyVal
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new HListCodecEnrichedWithHListSupport(self: Codec[L])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##(): Int
    Definition Classes
    Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from HListCodecEnrichedWithHListSupport[L] to any2stringadd[HListCodecEnrichedWithHListSupport[L]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (HListCodecEnrichedWithHListSupport[L], B)
    Implicit
    This member is added by an implicit conversion from HListCodecEnrichedWithHListSupport[L] to ArrowAssoc[HListCodecEnrichedWithHListSupport[L]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. def :+[B, LB <: HList](codec: Codec[B])(implicit prepend: shapeless.ops.hlist.Prepend.Aux[L, ::[B, HNil], LB], init: Aux[LB, L], 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.

  6. def ::[B](codec: Codec[B]): Codec[::[B, L]]

    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

  7. def :::[K <: HList, KL <: HList, KLen <: Nat](k: Codec[K])(implicit prepend: shapeless.ops.hlist.Prepend.Aux[K, L, KL], lengthK: Aux[K, KLen], split: Aux[KL, KLen, K, L]): Codec[KL]

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

  8. def :~>:[B](codec: Codec[B])(implicit ev: =:=[Unit, B]): Codec[L]

    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 ~>.

  9. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  10. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  11. def derive[A]: DeriveHListElementAux[L, A]

    Supports building a Codec[M] for some HList M where M is the HList that results in removing the first A from L.

    Supports building a Codec[M] for some HList M where M is the HList that results in removing the first A from L.

    Example usage:

    case class Flags(x: Boolean, y: Boolean, z: Boolean)
    val c = (bool :: bool :: bool :: ignore(5)).flatPrepend { flgs =>
      conditional(flgs.x, uint8) :: conditional(flgs.y, uint8) :: conditional(flgs.z, uint8)
    }
    c.derive[Flags].from { case x :: y :: z :: HNil => Flags(x.isDefined, y.isDefined, z.isDefined) }

    This codec, the Codec[L], is used for encoding/decoding. When decoding, the first value of type A is removed from the HList.

    When encoding, the returned codec computes an A value using the supplied function and inserts the computed A in to the HList M, yielding an HList L. That HList L is then encoded using the original codec.

    This method is called derive because the value of type A is derived from the other fields in the HList L.

    A

    type to remove from L and derive from the resulting list

  12. def dropUnits[M <: HList](implicit du: Aux[L, M]): Codec[M]

    Creates a new codec with all unit values filtered out.

  13. def ensuring(cond: (HListCodecEnrichedWithHListSupport[L]) ⇒ Boolean, msg: ⇒ Any): HListCodecEnrichedWithHListSupport[L]
    Implicit
    This member is added by an implicit conversion from HListCodecEnrichedWithHListSupport[L] to Ensuring[HListCodecEnrichedWithHListSupport[L]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: (HListCodecEnrichedWithHListSupport[L]) ⇒ Boolean): HListCodecEnrichedWithHListSupport[L]
    Implicit
    This member is added by an implicit conversion from HListCodecEnrichedWithHListSupport[L] to Ensuring[HListCodecEnrichedWithHListSupport[L]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: Boolean, msg: ⇒ Any): HListCodecEnrichedWithHListSupport[L]
    Implicit
    This member is added by an implicit conversion from HListCodecEnrichedWithHListSupport[L] to Ensuring[HListCodecEnrichedWithHListSupport[L]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. def ensuring(cond: Boolean): HListCodecEnrichedWithHListSupport[L]
    Implicit
    This member is added by an implicit conversion from HListCodecEnrichedWithHListSupport[L] to Ensuring[HListCodecEnrichedWithHListSupport[L]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. def flatAppend[A, LA <: HList, Len <: Nat](f: (L) ⇒ Codec[A])(implicit prepend: shapeless.ops.hlist.Prepend.Aux[L, ::[A, HNil], LA], length: Aux[L, Len], split: Aux[LA, Len, L, ::[A, HNil]]): Codec[LA]

    When called on a Codec[L] for some L <: HList, returns a new codec that encodes/decodes the HList L followed by the value A, where the latter is encoded/decoded with the codec returned from applying L to f.

  18. def flatConcat[M <: HList, LM <: HList, LLen <: Nat](f: (L) ⇒ Codec[M])(implicit prepend: shapeless.ops.hlist.Prepend.Aux[L, M, LM], lengthK: Aux[L, LLen], split: Aux[LM, LLen, L, M]): Codec[LM]

    When called on a Codec[L] for some L <: HList, returns a new codec that encodes/decodes the HList L followed by the HList M, where the latter is encoded/decoded with the codec returned from applying L to f.

  19. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from HListCodecEnrichedWithHListSupport[L] to StringFormat[HListCodecEnrichedWithHListSupport[L]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  20. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  21. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  22. def polyxmap[M <: HList](p: Poly, q: Poly)(implicit lToM: Aux[p.type, L, M], mToL: Aux[q.type, M, L]): Codec[M]

    Polymorphic function version of xmap.

    Polymorphic function version of xmap.

    When called on a Codec[L] for some L <: HList, returns a new codec that's the result of xmapping with p and q, using p to convert from L to M and using q to convert from M to L.

    p

    polymorphic function that converts from L to M

    q

    polymorphic function that converts from M to L

  23. def polyxmap1[M <: HList](p: Poly)(implicit m: Aux[p.type, L, M], m2: Aux[p.type, M, L]): Codec[M]

    Polymorphic function version of xmap that uses a single polymorphic function in both directions.

    Polymorphic function version of xmap that uses a single polymorphic function in both directions.

    When called on a Codec[L] for some L <: HList, returns a new codec that's the result of xmapping with p for both forward and reverse directions.

    p

    polymorphic function that converts from L to M and from M to L

  24. val self: Codec[L]
  25. def toString(): String
    Definition Classes
    Any
  26. def [B](y: B): (HListCodecEnrichedWithHListSupport[L], B)
    Implicit
    This member is added by an implicit conversion from HListCodecEnrichedWithHListSupport[L] to ArrowAssoc[HListCodecEnrichedWithHListSupport[L]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from AnyVal

Inherited from Any

Inherited by implicit conversion any2stringadd from HListCodecEnrichedWithHListSupport[L] to any2stringadd[HListCodecEnrichedWithHListSupport[L]]

Inherited by implicit conversion StringFormat from HListCodecEnrichedWithHListSupport[L] to StringFormat[HListCodecEnrichedWithHListSupport[L]]

Inherited by implicit conversion Ensuring from HListCodecEnrichedWithHListSupport[L] to Ensuring[HListCodecEnrichedWithHListSupport[L]]

Inherited by implicit conversion ArrowAssoc from HListCodecEnrichedWithHListSupport[L] to ArrowAssoc[HListCodecEnrichedWithHListSupport[L]]

generic

hlist

Ungrouped