RemainingLengthCodec

final class RemainingLengthCodec extends Codec[Int]
trait Codec[Int]
trait Decoder[Int]
trait Encoder[Int]
class Object
trait Matchable
class Any

Value members

Concrete methods

def decode(bits: BitVector): Attempt[DecodeResult[Int]]
def encode(value: Int): Attempt[BitVector]
def sizeBound: SizeBound

Inherited methods

final def <~[B](codecB: Codec[B])(using Unit =:= B): Codec[Int]

Assuming B is Unit, creates a Codec[A] that: encodes the A followed by a unit; decodes an A followed by a unit and discards the decoded unit.

Assuming B is Unit, creates a Codec[A] that: encodes the A followed by a unit; decodes an A followed by a unit and discards the decoded unit.

Operator alias of dropRight.

Inherited from
Codec
final def >>~[B](f: Int => Codec[B]): Codec[(Int, B)]

Returns a new codec that encodes/decodes a value of type (A, B) where the codec of B is dependent on A. Operator alias for flatZip.

Returns a new codec that encodes/decodes a value of type (A, B) where the codec of B is dependent on A. Operator alias for flatZip.

Inherited from
Codec
def as[B](using iso: Iso[Int, B]): Codec[B]

Transforms this codec to a Codec[B] if A is isomorphic to B.

Transforms this codec to a Codec[B] if A is isomorphic to B.

This is most commonly used to convert a tuple codec to a case class:

Example
case class Point(x: Int, y: Int, z: Int)
val c: Codec[(Int, Int, Int)] = int8 :: int8 :: int8
val p: Codec[Point] = c.as[Point]
Inherited from
Codec
def asDecoder: Decoder[Int]

Gets this as a Decoder.

Gets this as a Decoder.

Inherited from
Decoder
def asEncoder: Encoder[Int]

Gets this as an Encoder.

Gets this as an Encoder.

Inherited from
Encoder
def collect[F[_], A2 >: Int](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.

Inherited from
Decoder
final override def compact: Codec[Int]
Definition Classes
Codec -> Encoder
Inherited from
Codec
final override def complete: Codec[Int]
Definition Classes
Codec -> Decoder
Inherited from
Codec
final def consume[B](f: Int => Codec[B])(g: B => Int): Codec[B]

Similar to flatZip except the A type is not visible in the resulting type -- the binary effects of the Codec[A] still occur though.

Similar to flatZip except the A type is not visible in the resulting type -- the binary effects of the Codec[A] still occur though.

Example usage:

     case class Flags(x: Boolean, y: Boolean, z: Boolean)
     (bool :: bool :: bool :: ignore(5)).consume { flgs =>
       conditional(flgs.x, uint8) :: conditional(flgs.y, uint8) :: conditional(flgs.z, uint8)
     } {
       case (x, y, z) => Flags(x.isDefined, y.isDefined, z.isDefined) }
     }
Inherited from
Codec
def contramap[B](f: B => Int): 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.

Inherited from
Encoder
final def decodeAll[B](f: Int => 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

Inherited from
Decoder
override def decodeOnly[AA >: Int]: Codec[AA]
Definition Classes
Codec -> Decoder
Inherited from
Codec
final def decodeValue(bits: BitVector): Attempt[Int]

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 Params
bits

bits to decode

Returns

error if value could not be decoded or the decoded value

Inherited from
Decoder
final def downcast[B <: Int](using TypeTest[A, B]): Codec[B]

Safely lifts this codec to a codec of a subtype.

Safely lifts this codec to a codec of a subtype.

When a supertype of B that is not a supertype of A is decoded, an decoding error is returned.

Inherited from
Codec
final def dropLeft[B](codecB: Codec[B])(using ev: Unit =:= Int): Codec[B]

Assuming A is Unit, creates a Codec[B] that: encodes the unit followed by a B; decodes a unit followed by a B and discards the decoded unit.

Assuming A is Unit, creates a Codec[B] that: encodes the unit followed by a B; decodes a unit followed by a B and discards the decoded unit.

Inherited from
Codec
final def dropRight[B](codecB: Codec[B])(using ev: Unit =:= B): Codec[Int]

Assuming B is Unit, creates a Codec[A] that: encodes the A followed by a unit; decodes an A followed by a unit and discards the decoded unit.

Assuming B is Unit, creates a Codec[A] that: encodes the A followed by a unit; decodes an A followed by a unit and discards the decoded unit.

Inherited from
Codec
def econtramap[B](f: B => Attempt[Int]): 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].

Inherited from
Encoder
def emap[B](f: Int => 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].

Inherited from
Decoder
def encodeAll(as: Iterable[Int]): 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.

Inherited from
Encoder
def encodeOnly: Codec[Int]

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

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

Inherited from
Encoder
final def exmap[B](f: Int => Attempt[B], g: B => Attempt[Int]): Codec[B]

Transforms using two functions, A => Attempt[B] and B => Attempt[A].

Transforms using two functions, A => Attempt[B] and B => Attempt[A].

Inherited from
Codec
def flatMap[B](f: Int => 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].

Inherited from
Decoder
final def flatZip[B](f: Int => Codec[B]): Codec[(Int, B)]

Returns a new codec that encodes/decodes a value of type (A, B) where the codec of B is dependent on A.

Returns a new codec that encodes/decodes a value of type (A, B) where the codec of B is dependent on A.

Inherited from
Codec
def map[B](f: Int => 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.

Inherited from
Decoder
def pcontramap[B](f: B => Option[Int]): 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.

Inherited from
Encoder
final def tuple: Codec[Int *: EmptyTuple]

Lifts this codec in to a codec of a singleton tuple.

Lifts this codec in to a codec of a singleton tuple.

Inherited from
Codec
final def unit(zero: Int): Codec[Unit]

Converts this to a Codec[Unit] that encodes using the specified zero value and decodes a unit value when this codec decodes an A successfully.

Converts this to a Codec[Unit] that encodes using the specified zero value and decodes a unit value when this codec decodes an A successfully.

Inherited from
Codec
final def upcast[B >: Int](using TypeTest[B, A]): Codec[B]

Safely lifts this codec to a codec of a supertype.

Safely lifts this codec to a codec of a supertype.

When a subtype of B that is not a subtype of A is passed to encode, an encoding error is returned.

Inherited from
Codec
final def withContext(context: String): Codec[Int]

Creates a new codec that is functionally equivalent to this codec but pushes the specified context string in to any errors returned from encode or decode.

Creates a new codec that is functionally equivalent to this codec but pushes the specified context string in to any errors returned from encode or decode.

Inherited from
Codec
final def withToString(str: => String): Codec[Int]

Creates a new codec that is functionally equivalent to this codec but returns the specified string from toString.

Creates a new codec that is functionally equivalent to this codec but returns the specified string from toString.

Inherited from
Codec
final def xmap[B](f: Int => B, g: B => Int): Codec[B]

Transforms using the isomorphism described by two functions, A => B and B => A.

Transforms using the isomorphism described by two functions, A => B and B => A.

Inherited from
Codec
final def ~>[B](codecB: Codec[B])(using Unit =:= A): Codec[B]

Assuming A is Unit, creates a Codec[B] that: encodes the unit followed by a B; decodes a unit followed by a B and discards the decoded unit.

Assuming A is Unit, creates a Codec[B] that: encodes the unit followed by a B; decodes a unit followed by a B and discards the decoded unit.

Operator alias of dropLeft.

Inherited from
Codec

Deprecated and Inherited methods

@deprecated("Use .tuple instead", "2.0.0")
final def hlist: Codec[Int *: EmptyTuple]
Deprecated
Inherited from
Codec

Concrete fields

val MaxValue: Int
val MinValue: Int