Velocypack decoder

VPackDecoder[T] decodes vpack values to scala values VPack => Either[VPackError, T]

By importing avokka.velocypack._ you bring two helpers to BitVector having an implicit VPackDecoder :

  • asVPack[T] for decoding a single type T
import avokka.velocypack._
import scodec.bits._

val bits = hex"02043334".bits
// bits: BitVector = BitVector(32 bits, 0x02043334)

bits.asVPack[Vector[Long]]
// res0: Either[VPackError, DecodeResult[Vector[Long]]] = Right(DecodeResult(Vector(3, 4),BitVector(empty)))
  • asVPackSequence[T] for decoding a stream of type T
import avokka.velocypack._
import scodec.bits._

val bitstream = hex"353637".bits
// bitstream: BitVector = BitVector(24 bits, 0x353637)

bitstream.asVPackSequence[Long]
// res1: Either[VPackError, DecodeResult[Vector[Long]]] = Right(DecodeResult(Vector(5, 6, 7),BitVector(empty)))