- Built for 2.12.0-RC2
- Upgraded to scodec-bits 1.1.2
- Built for 2.12.0-M5
- Added
lpbcdfor working with left padded BCD integers.
- Upgraded to shapeless 2.3.1
- Upgraded to scodec-bits 1.1.0
- Added new
bitsRemainingcodec, which decodestrueif a non-empty vector is encountered. - Fixed bug in
listOfN/vectorOfNsuch that decoding now fails if less thannelements are decoded. - Added
framingtoCoproductCodecBuilder, allowing aCodecTransformationto be applied to all cases. - Added support for deriving recursive case classes and ADTs.
- Added support for
ascombinator onEncoderandDecoder. - Added support for packed decimals (
pbcd,vpbcd). - Added
sizedList/sizedVectorcodecs, which encode/decode collections of a statically known size. - Fixed bug in
variableSizeByteswhere, if the wrapped codec generates a vector which has a size not evenly divisible by 8, the vector was truncated to next lowest byte boundary.
- Restored support for Android 4.3 and lower.
- Deprecated
DecodingContext, as it is equal in power toflatMaponCodec/Decoder. - Added
bindmethod toDiscriminated, allowing less boilerplate in creatingDiscriminatorinstances. - Fixed bug in
listDelimitedcodec. - Minor optimizations, including faster
UUIDcodec and upgrade to scodec-bits 1.0.10, which has additional performance improvements.
- Added
xmapc,exmapc,narrowc, andwidencmethods toCodecand other types withTransforminstances. These methods are curried versions of their non-curried counterparts, allowing the resulting type to be inferred based on result of first function. For example,bits.xmap[ByteVector](_.bytes, _.bits)can now be written asbits.xmapc(_.bytes)(_.bits). - Added
vint,vintL,vlong, andvlongLcodecs, which encode integers in a variable number of bytes. - Fixed source links in ScalaDoc.
- Upgraded to scodec-bits 1.0.9, shapeless 2.2.4, scala 2.11.7, and scala.js 0.6.4.
- Added support for Scala.js.
- Changed
DiscriminatorCodec#typecaseto take aClassTaginstead of aManfiest. - Changed
Codec#{upcast,downcast}to take aTypeableinstance instead of aManifest, in order to avoid Java reflection. - Changed
withToStringto take its argument by-name, so that string formatting/interpolation only occurs whentoStringis called. - Added
vectorMultiplexed/listMultiplexedcombinators, for creating aCodec[Vector[A]]/Codec[List[A]]from aCodec[A]and custom multiplexing/demultiplexing logic. - Added
vectorDelimited/listDelimitedcombinators, for creating aCodec[Vector[A]]/Codec[List[A]]from aCodec[A]and a delimiter, expressed as aBitVector. - Added
cstringcodec, for encoding/decodingUS-ASCIIstrings that are terminated by a NUL (0) byte.
- Added
byteAlignedcombinator, which right pads aCodec[A]such that the binary size is always evenly divisible by 8. - Added
decodeValueback toDecoder,Codec, andGenCodec. - Added
limitedSizeBitsandlimitedSizeBytescombinators, which behave likefixedSizeBits/fixedSizeBytesbut perform no padding. - Added support for value codec framing to
DiscriminatorCodecand auto-generated coproduct codecs. SeeTlvExamplefor usage. - Added
fallbackanddiscriminatorFallbackcombinators. - Added
variableSizePrefixed{Bits,Bytes}andvariableSizePrefixed{Bits,Bytes}Longcombinators for working with binary shapes likesize ++ prefix ++ valuewheresizeencodes the length ofvalue. - The
.as[CaseClass]syntax now automatically drops unit values from theHListrepresentation. - Improved support for derived fields in
HListcodecs -- fields which appear in the binary format but should not appear in theHListtype. See ProductExamples.- Added
derive[A].from(f)syntax onCodec[L]for someL <: HListto simplify working with fields whose value are derived from other fields. - Added
consume(f)(g)syntax onCodec[A]as an alias for the patternflatPrepend(f).derive[A].from(g).
- Added
- Added
filteredcombinator, which allows post-processing of encoded binary and pre-processing of to-be-decoded binary. - Added
checksummedcombinator, which allows simpler checksumming than working with signature codecs.
- Added
string32,ascii32, andutf8_32codecs, which encode a 32-bit 2s complement big endian size field before the string encoding. - Added various combinators for logging results of encoding/decoding --
logBuilder,logFailuresBuilder,logSuccessesBuilder,logToStdOut, andlogFailuresToStdOut. - Added
zlibcombinator, which compresses the results of another codec. - Fixed bug where the contents of the scodec-bits jar was included in the scodec-core jar.
- Group id (ivy organization) changed from
org.typeleveltoorg.scodec. - Upgraded to Shapeless 2.1 and removed the dependency on Scalaz. Users must use Shapeless 2.1.x, as the 2.1 series is not binary compatible with the 2.0 series.
- As a result of the Shapeless 2.1 upgrade, Scala 2.10 users are required to use the Macro Paradise compiler plugin. Scala 2.11 users do not need Macro Paradise. For cross builds, the following SBT setting will add the plugin to only your 2.10 build:
// Shapeless 2.1.0 on Scala 2.10 requires macro paradise
libraryDependencies ++= {
if (scalaBinaryVersion.value startsWith "2.10") Seq(compilerPlugin("org.scalamacros" % "paradise" % "2.0.1" cross CrossVersion.full)) else Nil
}- Derived codecs now work for arbitrarily complex structures. In previous versions, deriving codecs for some complex types would result in implicit divergence, requiring, for instance, users to manually define implicit codecs for each component type before deriving a product codec. These limitations have been removed.
- Related to the fixes for derivation of complex structures, the
ImplicitCodecandDerivedCodectypes have been removed in favor ofshapeless.Lazy[Codec[A]]. If authoring combinators that require implicit codecs, useLazy[Codec[A]]instead ofCodec[A]orImplicitCodec[A]. The same advice holds for implicit encoders and decoders -- useLazy[Encoder[A]]andLazy[Decoder[A]]. - All uses of
scalaz.\/were replaced withscodec.Attempt, which is isomorphic toErr \/ ?. See the ScalaDoc forAttemptfor combinators. Some specific notes:- The return type of
encodehas changed fromErr \/ BitVectortoAttempt[BitVector]. - The return type of
decodehas changed fromErr \/ (BitVector, A)toAttempt[DecodeResult[A]].DecodeResultis a case class that contains both theAvalue as well as the remainderBitVector. It contains two useful methods,mapandmapRemainder, which makes it nicer to work with thanTuple2. - Replace
codec.encodeValid(a)withcodec.encode(a).require - Replace
codec.decodeValid(a)withcodec.decode(a).require - Replace
codec.decodeValidValue(a)withcodec.decode(a).require.value
- The return type of
- Scalaz type class instances moved to the
scodec.interop.scalazpackage, in the scodec-scalaz library. This library contains additional conveniences for Scalaz users, like syntax for converting betweenAttempt[A]andErr \/ A. In general, you should importscodec.interop.scalaz._. - Another new interop library is available as of scodec-core 1.7 -- scodec-spire, which provides codecs for unsigned numeric types.
scodec.DecodingContextis significantly faster. If you previously avoided using it due to performance overhead, retest the new implementation.- Dramatically improved compile time of
dropUnits - Introduced new
codec.flattenLeftPairscombinator, which converts aCodec[(((A, B), C, ...)]to aCodec[A :: B :: C :: ... :: HNil] - Introduced new combinators for building
Tuple3throughTuple12codecs and binding the results to case classes. Callinga ~~ bwherea: Codec[TupleM[...]]results in aCodec[TupleN[..., B]]whereN = M + 1. The~~operator differs from~in that it returns a codec for a tuple of one higher arity than the left hand side codec. And specifically, it returns ascodec.codecs.TupleNCodec, whereNis replaced by the arity. To bind aTupleNCodecto a case class, callwidenAs(Foo.apply, Foo.unapply). The advantage of using~~is that aTupleNis created directly when decoding, avoiding the nestedTuple2instances generated by~. - Introduced a new abstract method on
Encoder--def sizeBound: SizeBound, which provides lower and upper bounds on the size of the encoded binary. If a definition forsizeBounddoes not apply to a codec, define the method asdef sizeBound = SizeBound.unknown. The built-combinators have been updated to compute size bounds correctly, even for product and coproduct types.
CoproductCodecBuildernow supports arbitrary orderings of component types. This is especially useful when creating aCoproductCodecBuilderfor a sealed class, because the order of subtypes in the coproduct representation is chosen by the compiler. See example.- Introduced the
Transformtypeclass, which abstracts the ability toexmapand provides derived implementations forxmap,pxmap,widen,narrow, andas, including Shapeless integration withas. - Provided instances of
Transformfor bothCodecandCoproductCodecBuilder. - Added various combinators to
Codec:upcastdowncasttoFieldWithContext
- Introduced
KnownDiscriminatorType[D]mixin. - Modified discriminated coproduct codecs and
DiscriminatorCodecto raiseKnownDiscriminatorType[D]#UnknownDiscriminatorerrors. - Added
scodec.codecs.hlist(l)combinator for converting anHListof shapeCodec[X0] :: Codec[X1] :: ... :: Codec[Xn] :: HNiltoCodec[X0 :: X1 :: ... :: Xn :: HNil]. Also available via syntax enrichment,toCodec, onHLists of proper shape.
- Due to diverging implicit errors introduced by 1.4.0, the derived codec support was refactored.
For non-generic uses, the syntax is the same -- call
Codec[Foo]to auto-derive a codec forFoo. For generic uses, combinators should be changed to take an implicitImplicitCodec[A]instead of an implicitCodec[A]. See the issue for more details on the problem and the PR for more details on the new structure. - Fixed a bug in
ushort8where it was treating binary as a signedshort8. - Added
withContexttoCodec-- this is an alias for"context" | codec.
- Breaking Change - Changed error type from String to
scodec.Err.Erris a non-sealed class, allowing codecs to return custom subtypes describing domain specific errors. This allows dispatching on those domain specific errors. To upgrade, instead of returning a string, wrap the string withErr(str). See the PR for details. - Added
Codec.coproduct, which helps createCoproductbased codecs. See CoproductsExample. - Added support for automatically deriving codecs, based on
Codec.productandCodec.coproduct. See DerivedCodecExamples. - Added
scodec.codecs.implicits, which provides implicit codecs for primitive values and collections. - Updated
paddedFixedSize{Bits,Bytes}Dependentcombinator for building PKCS5/PKCS7 style padding.
- Added
flatAppendandflatConcattoHListbased codecs. - Added
Codec.product, which automatically generatesHListbased codecs for case classes andHListtypes if all component types have implicit codecs available. See ProductsExample. - Added the
toFieldcombinator toCodec, allowing creation of Shapeless field codecs from value codecs. That is,toField[K]onCodecconverts aCodec[A]to aCodec[FieldType[K, A]] - Added
variableSize{Bits,Bytes}Longas alternatives tovariableSize{Bits,Bytes}, where the size is encoded/decoded via aCodec[Long]instead of aCodec[Int].
- Added support for Shapeless coproduct codecs. See
CoproductCodecTestfor examples. - Added
exmaptoCodec,emaptoDecoderandecontramaptoEncoder - Added
narrowandwidentoCodec - Added ability to lift an
Encoderto aCodecviaencodeOnlyand aDecoderto aCodecviadecodeOnly - Added
paddedFixedSize{Bytes,Bits}combinators - Added numeric codecs for
ShortandByte - Fixed bug in
constantLenientwhere decoding wasn't lenient
- Changed
dropLeft/~>anddropRight/<~to require aCodec[Unit]on the dropped side. Previously, the requirement was aCodec[X]and an implicitly availableMonoid[X]. To convert aCodec[X]to aCodec[Unit], use theunitcombinator. - Changed size based codecs to use
Longinstead ofIntsizes.
- Added support for Shapeless coproduct codecs. See
CoproductCodecTestfor examples. - Added
exmaptoCodec,emaptoDecoderandecontramaptoEncoder - Added
narrowandwidentoCodec - Added ability to lift an
Encoderto aCodecviaencodeOnlyand aDecoderto aCodecviadecodeOnly - Added
paddedFixedSize{Bytes,Bits}combinators - Added numeric codecs for
ShortandByte - Fixed bug in
constantLenientwhere decoding wasn't lenient
- Added
failcombinator - Added
mappedEnumcombinator - Added
vectorandlistcombinators and deprecatedrepeated - Added
vectorOfNandlistOfNcombinators for count encoded values - Added
unitandunitMcombinators to convert aCodec[A]to aCodec[Unit] - Added
scodec.codecs.literals._for implicitly converting literal values to constant codecs. - Added
constantLenientcodec that's equivalent toconstantbut does not validate that the decoded bits equal the constant value - Improved support for
asmethod:- Better compiler error message when an implicit
CodecAsAuxis not found - Support for reverse bindings (e.g.,
Codec[Point3D].as[Int :: Int :: Int :: HNil]) - Support for singleton bindings without having to first lift
Codec[A]toCodec[A :: HNil](e.g.,case class Foo(x: Int); uint8.as[Foo])
- Better compiler error message when an implicit
- Added
optionalcombinator - Added
withDefaultandwithDefaultValuecombinators - Added
recoverandlookaheadcombinators - Added
dropUnitscombinator forHListcodecs, greatly simplifying creation of codecs that have unit values due to use ofconstantorignore. For example,(uint8 :: ignore(4) :: uint4 :: ignore(3) :: uint5).dropUnitsresults in aCodec[Int :: Int :: Int :: HNil] - Added support for xmapping polymorphic functions via
polyxmapandpolyxmapcombinators polyxmaptakes 2 polymorphic functions, forward and reversepolyxmap1takes 1 polymorphic function that's used in both directions- both combinators work on
HListcodecs and value codecs
- Upgraded to Scalaz 7.1.0
- Published ScalaDoc links in POM so that other projects can link to ScalaDoc
- Upgraded to Shapeless 2
- Added
endiannessDependentcombinator - Used
scodec.bits.ByteOrderinginstead of a boolean for indicating big endian vs little endian - Significant performance improvements
- Upgrade to scodec-bits 1.0.0-RC2
- Added
bitsandbytescodecs that behave likebits(size)/bytes(size)but with no size constraint - Replaced discriminator support with new implementation that is much more general (thanks to Paul C)
- Removed
Codec.{ encode, decode }overloads that aliasedCodec#{ encode, decode } - Introduced
encodeValid,decodeValue, anddecodeValidValuemethods on both theCodecclass and object - Added new combinators (
lazily,complete,compact) - API docs
- Removed unnecessary dependencies from pom
- Changed group id from com.github.scodec to org.typelevel
- Changed artifact id from scodec to scodec-core
- Deprecated
scodec.{ BitVector, ByteVector }in favor ofscodec.bits.{ BitVector, ByteVector }- Deprecated forwarders will be removed in M3
- Reduced public API
- made many types package private
- removed methods from
Codeccompanion that existed directly onCodec
- JAR restructuring
- scodec-bits: no dependency JAR containing BitVector, ByteVector, and supporting types
- scodec: dependds on scodec-bits and adds encoding/decoding capabilities
- See scodec-bits for list of improvements to BitVector and ByteVector
- Package restructuring
- scodec.bits package contains BitVector, ByteVector, and supporting types
- scodec package contains main abstractions of encoding/decoding
- scodec.codecs package contains reusable codecs
- Encoder, Decoder, and GenCodec abstractions, which allow simpler transforms if a full Codec is not required