Decoder

trait Decoder[+A]

Supports decoding a value of type A from a BitVector.

Companion
object
class Object
trait Matchable
class Any
trait Codec[A]
class DiscriminatorCodec[A, B]

Document{}

def decode(bits: BitVector): Attempt[DecodeResult[A]]

Attempts to decode a value of type A from the specified bit vector.

Value Params
bits

bits to decode

Returns

error if value could not be decoded or the remaining bits and the decoded value

final def decodeValue(bits: BitVector): Attempt[A]

Attempts to decode a value of type A from the specified bit vector and discards the remaining bits.

Value Params
bits

bits to decode

Returns

error if value could not be decoded or the decoded value

def map[B](f: A => B): Decoder[B]

Converts this decoder to a Decoder[B] using the supplied A => B.

def flatMap[B](f: A => Decoder[B]): Decoder[B]

Converts this decoder to a Decoder[B] using the supplied A => Decoder[B].

def emap[B](f: A => Attempt[B]): Decoder[B]

Converts this decoder to a Decoder[B] using the supplied A => Attempt[B].

def complete: Decoder[A]

Converts this decoder to a new decoder that fails decoding if there are remaining bits.

Gets this as a Decoder.

def decodeOnly[AA >: A]: Codec[AA]

Converts this to a codec that fails encoding with an error.

final def decodeAll[B](f: A => B)(zero: B, append: (B, B) => B)(buffer: BitVector): (Option[Err], B)

Repeatedly decodes values of type A from the specified vector, converts each value to a B and appends it to an accumulator of type B using the supplied zero value and append function. Terminates when no more bits are available in the vector. Exits upon first decoding error.

Returns

tuple consisting of the terminating error if any and the accumulated value

def collect[F[_], A2 >: A](buffer: BitVector, limit: Option[Int])(using factory: Factory[A2, F[A2]]): Attempt[DecodeResult[F[A2]]]

Repeatedly decodes values of type A from the specified vector and returns a collection of the specified type. Terminates when no more bits are available in the vector or when limit is defined and that many records have been decoded. Exits upon first decoding error.

Value members

Methods

def as: Decoder[B]
Extension method from Decoder