Encoder

trait Encoder[-A]

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]

Document{}

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

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.

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

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

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.

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

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

def compact: Encoder[A]

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

Gets this as an Encoder.

def encodeOnly: Codec[A]

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

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

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

Value members

Methods

def as: Encoder[B]
Extension method from Encoder