ByteDecoder

org.sigilaris.core.codec.byte.ByteDecoder
See theByteDecoder companion trait
object ByteDecoder

Attributes

Companion
trait
Source
ByteDecoder.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

object ops

Extension methods for decoding bytes to values.

Extension methods for decoding bytes to values.

Attributes

Source
ByteDecoder.scala
Supertypes
class Object
trait Matchable
class Any
Self type
ops.type

Types

type BigNat = IronType[BigInt, Positive0]

Natural number type (non-negative BigInt).

Natural number type (non-negative BigInt).

Attributes

Source
ByteDecoder.scala

Value members

Concrete methods

Summons a ByteDecoder instance for type A.

Summons a ByteDecoder instance for type A.

Attributes

Source
ByteDecoder.scala
def failed[A](msg: String): ByteDecoder[A]

Creates a decoder that always fails with the given message.

Creates a decoder that always fails with the given message.

Type parameters

A

the target type (never actually produced)

Value parameters

msg

the failure message

Attributes

Returns

a decoder that always returns a DecodeFailure

Source
ByteDecoder.scala
def fromFixedSizeBytes[T : ClassTag](size: Long)(f: ByteVector => T): ByteDecoder[T]

Creates a decoder for fixed-size byte representations.

Creates a decoder for fixed-size byte representations.

Value parameters

f

function to convert bytes to value

size

number of bytes to consume

Attributes

Returns

decoder that reads exactly size bytes

Source
ByteDecoder.scala
def sizedListDecoder[A : ByteDecoder](size: BigNat): ByteDecoder[List[A]]

Creates a decoder for List with known size.

Creates a decoder for List with known size.

Type parameters

A

the element type

Value parameters

size

number of elements to decode

Attributes

Returns

decoder that reads exactly size elements

Source
ByteDecoder.scala
inline def summonAll[T <: Tuple]: List[ByteDecoder[_]]

Attributes

Source
ByteDecoder.scala
def unsafeFromBigInt(n: BigInt): BigNat

Unsafe conversion from BigInt to BigNat (internal use).

Unsafe conversion from BigInt to BigNat (internal use).

Attributes

Source
ByteDecoder.scala

Givens

Givens

Decodes signed integers using sign-magnitude decoding.

Decodes signed integers using sign-magnitude decoding.

Decoding transformation:

  • Even x: decode as x / 2
  • Odd x: decode as (x - 1) / (-2)

This is the inverse of BigInt encoding.

Attributes

See also

types.md for BigInt decoding examples

Source
ByteDecoder.scala

Decodes natural numbers with variable-length encoding.

Decodes natural numbers with variable-length encoding.

Decoding rules:

  • 0x00 ~ 0x80: value is the byte itself
  • 0x81 ~ 0xf8: length = byte - 0x80, read 1-120 data bytes
  • 0xf9 ~ 0xff: read a canonical 2-8 byte length, then 121+ data bytes

Rejects leading-zero magnitudes, redundant short form for single-byte values, long form for magnitudes of 120 bytes or fewer, over-wide length fields, truncated input, and lengths above Long.MaxValue.

Attributes

See also

types.md for complete BigNat decoding specification

Source
ByteDecoder.scala
given booleanDecoder: ByteDecoder[Boolean]

Decodes Boolean from a canonical single-byte flag.

Decodes Boolean from a canonical single-byte flag.

Accepted encodings:

  • 0x00: false
  • 0x01: true

Any other leading byte fails.

Attributes

Source
ByteDecoder.scala
given byteDecoder: ByteDecoder[Byte]

Decodes Byte as single byte.

Decodes Byte as single byte.

Attributes

Source
ByteDecoder.scala
inline given derived[T](using p: ProductOf[T]): ByteDecoder[T]

Automatic derivation for product types (case classes, tuples).

Automatic derivation for product types (case classes, tuples).

Decodes each field in order.

Attributes

See also

types.md for product decoding details

Source
ByteDecoder.scala
given instantDecoder: ByteDecoder[Instant]

Decodes Instant from epoch milliseconds (Long decoding).

Decodes Instant from epoch milliseconds (Long decoding).

Attributes

See also

types.md for Instant decoding rules

Source
ByteDecoder.scala
given longDecoder: ByteDecoder[Long]

Decodes Long as 8-byte big-endian representation.

Decodes Long as 8-byte big-endian representation.

Attributes

Source
ByteDecoder.scala
given mapByteDecoder[K : ByteDecoder, V : ByteDecoder]: ByteDecoder[Map[K, V]]

Decodes Map from deterministically ordered tuples.

Decodes Map from deterministically ordered tuples.

Reads size as BigNat, then decodes list of tuples, converting to Map.

Attributes

See also

types.md for Map decoding rules

Source
ByteDecoder.scala
given optionByteDecoder[A : ByteDecoder]: ByteDecoder[Option[A]]

Decodes Option as zero or one-element List.

Decodes Option as zero or one-element List.

Reads size as BigNat, then decodes list, taking head as Option.

Attributes

See also

types.md for Option decoding rules

Source
ByteDecoder.scala
given setByteDecoder[A : ByteDecoder]: ByteDecoder[Set[A]]

Decodes Set from deterministically ordered elements.

Decodes Set from deterministically ordered elements.

Reads size as BigNat, then decodes list, converting to Set.

Attributes

See also

types.md for Set decoding rules

Source
ByteDecoder.scala

Decodes Unit (consumes no bytes).

Decodes Unit (consumes no bytes).

Attributes

See also

types.md for Unit decoding rules

Source
ByteDecoder.scala