Questions tagged [scodec]

scodec is a pure functional Scala library that allows encoding/decoding of binary data.

scodec is a suite of Scala combinator libraries for working with binary data. Support ranges from simple, performant data structures for working with bits and bytes to streaming encoding and decoding.

This library focuses on contract-first and pure functional encoding and decoding of binary data. The following design constraints are considered:

  • Binary structure should mirror protocol definitions and be self-evident under casual reading
  • Mapping binary structures to types should be statically verified
  • Encoding and decoding should be purely functional
  • Failures in encoding and decoding should provide descriptive errors Compiler plugin should not be used

As a result, the library is implemented as a combinator based DSL. Performance is considered but yields to the above design constraints.

A good place to start using it is to look at the pre-existing codecs and how they can be combined by checking out the available operators.

Links: scodec.org and github.

35 questions
0
votes
1 answer

How to install scodec library in scala/sbt?

I have been asked by my developers to have scodec libraries installed on a linux server and I'm lost as I can't find any documentation that points about installing the scodec library!
0
votes
1 answer

How to ignore Codec after using it to limit size bytes

I would create a model for the KMIP protocols that works with TTLV encoding (Tag, Type, Length, Value) The ttlv function is "high level" and accepts the tag, the type and the codec of the value. def ttlv[A<:HList](tag:ByteVector, itype:ByteVector,…
Xamrix
  • 452
  • 3
  • 12
0
votes
1 answer

How do I make Codec[Option[T]] that is driven by prefix?

I'm trying to implement codec for PSQL COPY BINARY format. Details are at Tuple section Int, Bool, String fields are encoded as <4 byte length> I implemented them like this val psqlUtf8: Codec[String] = variableSizeBytes(int32,…
expert
  • 29,290
  • 30
  • 110
  • 214
0
votes
1 answer

Scodec - Literal binary unsigned integer string with length specified as input?

raw beginner with scodec here. Does scodec provide a nice way to convert an unsigned decimal integer value to a literal binary unsigned integer string with length specified as an input, left-padding with zeroes as needed up to the specified length?…
0
votes
2 answers

codec for a Vector[N] where N determines the end of the vector

I am using Scodec to decode Flac metadata. One of the specifications is that there is a Header and a Block that can be repeated a number of times together. Header has a flag which indicates if the current Header/Block combo is the last. I have…
Travis Stevens
  • 2,198
  • 2
  • 17
  • 25
1 2
3