MultiplexedCodec
sealed trait MultiplexedCodec
A trait that enables custom handling for encoding/decoding sequences.
class Object
trait Matchable
class Any
Value members
Methods
final def encode[A](enc: Encoder[A], mux: (BitVector, BitVector) => BitVector)(seq: Seq[A]): Attempt[BitVector]
Encodes all elements of the specified sequence and combines the results using
mux
, or returns the first encountered error.- Value Params
- enc
-
element encoder
- mux
-
multiplexing function
- seq
-
elements to encode
final def decode[F <: ([_$1] =>> Any), A](dec: Decoder[A], deMux: BitVector => (BitVector, BitVector))(buffer: BitVector)(cbf: Factory[A, F[A]]): Attempt[DecodeResult[F[A]]]
Repeatedly decodes values of type
Uses
Terminates when the next stream to decode is empty or upon first decoding error.
A
and returns a collection of the specified type.Uses
deMux
repeatedly to obtain the stream of vectors to decode to a value of type A
.Terminates when the next stream to decode is empty or upon first decoding error.
Note: For large sequences, it may be necessary to compact bits in
deMux
.- Value Params
- buffer
-
input bits
- deMux
-
returns
(next, rest)
tuples wherenext
is input todec
yielding(value, remainder)
andremainder ++ rest
is the next input todeMux
- dec
-
element decoder