Decoder

trait Decoder[+A]

Supports decoding a value of type A from a BitVector.

Companion:
object
Source:
Decoder.scala
class Object
trait Matchable
class Any
trait Codec[A]
class DiscriminatorCodec[A, B]

Value members

Abstract methods

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

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

Value parameters:
bits

bits to decode

Returns:

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

Source:
Decoder.scala

Concrete methods

def as: Decoder[B]
Extension method from Decoder

Gets this as a Decoder.

Gets this as a Decoder.

Source:
Decoder.scala
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.

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.

Source:
Decoder.scala

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

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

Source:
Decoder.scala
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.

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

Source:
Decoder.scala
def decodeOnly[AA >: A]: Codec[AA]

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

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

Source:
Decoder.scala
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.

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

Value parameters:
bits

bits to decode

Returns:

error if value could not be decoded or the decoded value

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

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

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

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

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

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

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

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

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

Source:
Decoder.scala