scodec

package scodec

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:

Source
package.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. scodec
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. sealed abstract class Attempt[+A] extends Product with Serializable

    Right biased Either[Err, A].

  2. trait Codec[A] extends GenCodec[A, A]

    Supports encoding a value of type A to a BitVector and decoding a BitVector to a value of A.

  3. type CodecTransformation = ~>[Codec, Codec]

    Universally quantified transformation of a Codec to a Codec.

  4. final case class DecodeResult[+A](value: A, remainder: BitVector) extends Product with Serializable

    Result of a decoding operation, which consists of the decoded value and the remaining bits that were not consumed by decoding.

  5. trait Decoder[+A] extends AnyRef

    Supports decoding a value of type A from a BitVector.

  6. trait DecoderFunctions extends AnyRef

    Provides functions for working with decoders.

  7. trait Encoder[-A] extends AnyRef

    Supports encoding a value of type A to a BitVector.

  8. trait EncoderFunctions extends AnyRef

    Provides functions for working with encoders.

  9. implicit final class EnrichedCoproductDecoder[C <: Coproduct] extends AnyVal

    Provides methods specific to decoders of Shapeless coproducts.

  10. implicit final class EnrichedCoproductEncoder[C <: Coproduct] extends AnyVal

    Provides methods specific to encoders of Shapeless coproducts.

  11. implicit final class EnrichedHList[L <: HList] extends AnyVal

    Provides additional methods on HLists.

  12. trait Err extends AnyRef

    Describes an error.

  13. trait GenCodec[-A, +B] extends Encoder[A] with Decoder[B]

    Generalized codec that allows the type to encode to vary from the type to decode.

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

    Provides common operations on a Codec[HList].

  15. final case class SizeBound(lowerBound: Long, upperBound: Option[Long]) extends Product with Serializable

    Bounds the size, in bits, of the binary encoding of a codec -- i.

  16. abstract class Transform[F[_]] extends AnyRef

    Typeclass that describes type constructors that support the exmap operation.

  17. implicit class TransformSyntax[F[_], A] extends AnyRef

    Provides method syntax for working with a type constructor that has a Transform typeclass instance.

  18. abstract class Transformer[A, B] extends AnyRef

    Witness operation that supports transforming an F[A] to an F[B] for all F which have a Transform instance available.

  19. implicit final class Tuple2CodecSupport[A] extends AnyVal

  20. implicit final class ValueCodecEnrichedWithGenericSupport[A] extends AnyVal

    Provides syntax related to generic programming for codecs of any type.

  21. implicit final class ValueCodecEnrichedWithHListSupport[A] extends AnyVal

    Provides HList related syntax for codecs of any type.

  22. sealed abstract class DecodingContext[A] extends AnyRef

    Provides the ability to sequence decoding operations such that the remainder of an operation is fed in to the input of the next operation.

Value Members

  1. object Attempt extends Serializable

    Companion for Attempt.

  2. object BuildInfo extends Product with Serializable

    This object was generated by sbt-buildinfo.

  3. object Codec extends EncoderFunctions with DecoderFunctions

    Companion for Codec.

  4. object CodecTransformation extends Serializable

    Companion for CodecTransformation.

  5. object Decoder extends DecoderFunctions

    Companion for Decoder.

  6. object DecodingContext

    Provides constructors for DecodingContext.

  7. object Encoder extends EncoderFunctions

    Companion for Encoder.

  8. object Err

    Companion for Err.

  9. object GenCodec extends EncoderFunctions with DecoderFunctions

    Companion for GenCodec.

  10. object SizeBound extends Serializable

    Companion for SizeBound.

  11. object Transform

    Companion for Transform.

  12. object Transformer

    Companion for Transformer.

  13. package codecs

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

Inherited from AnyRef

Inherited from Any

Ungrouped