Encoder

trait Encoder[-A]

Supports encoding a value of type A to a BitVector.

Supports encoding a value of type A to a BitVector.

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

Value members

Abstract methods

def encode(value: A): Attempt[BitVector]

Attempts to encode the specified value in to a bit vector.

Attempts to encode the specified value in to a bit vector.

Value Params
value

value to encode

Returns

error or binary encoding of the value

Provides a bound on the size of successfully encoded values.

Provides a bound on the size of successfully encoded values.

Concrete methods

def as: Encoder[B]
Extension method from Encoder

Gets this as an Encoder.

Gets this as an Encoder.

def compact: Encoder[A]

Converts this encoder to a new encoder that compacts the generated bit vector before returning it

Converts this encoder to a new encoder that compacts the generated bit vector before returning it

def contramap[B](f: B => A): Encoder[B]

Converts this encoder to an Encoder[B] using the supplied B => A.

Converts this encoder to an Encoder[B] using the supplied B => A.

def econtramap[B](f: B => Attempt[A]): Encoder[B]

Converts this encoder to an Encoder[B] using the supplied B => Attempt[A].

Converts this encoder to an Encoder[B] using the supplied B => Attempt[A].

def encodeAll(as: Iterable[A]): Attempt[BitVector]

Encodes all elements of the specified sequence and concatenates the results, or returns the first encountered error.

Encodes all elements of the specified sequence and concatenates the results, or returns the first encountered error.

def encodeOnly: Codec[A]

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

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

def pcontramap[B](f: B => Option[A]): Encoder[B]

Converts this encoder to an Encoder[B] using the supplied partial function from B to A. The encoding will fail for any B that f maps to None.

Converts this encoder to an Encoder[B] using the supplied partial function from B to A. The encoding will fail for any B that f maps to None.