ByteEncoder

org.sigilaris.core.codec.byte.ByteEncoder
See theByteEncoder companion trait
object ByteEncoder

Attributes

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

Members list

Type members

Classlikes

object ops

Extension methods for encoding values to bytes.

Extension methods for encoding values to bytes.

Attributes

Source
ByteEncoder.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
ByteEncoder.scala

Value members

Concrete methods

Summons a ByteEncoder instance for type A.

Summons a ByteEncoder instance for type A.

Attributes

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

Attributes

Source
ByteEncoder.scala

Givens

Givens

Encodes signed integers using sign-magnitude encoding.

Encodes signed integers using sign-magnitude encoding.

Encoding transformation:

  • Positive n: encode (n * 2) as BigNat
  • Negative n: encode (n * (-2) + 1) as BigNat

This ensures deterministic encoding while preserving sign information.

Attributes

See also

types.md for BigInt encoding examples

Source
ByteEncoder.scala

Encodes natural numbers with variable-length encoding.

Encodes natural numbers with variable-length encoding.

Encoding rules:

  • 0x00 ~ 0x80: single byte for values 0-128
  • 0x81 ~ 0xf7: [0x80+len][data] for 1-119 byte data
  • 0xf8: [0xf8][data] for exactly 120-byte data
  • 0xf9 ~ 0xff: [0xf8+(ll-1)][len][data] for 121+ byte data, where ll is at least 2

Attributes

See also

types.md for complete BigNat encoding specification

Source
ByteEncoder.scala
given booleanEncoder: ByteEncoder[Boolean]

Encodes Boolean as a canonical single-byte flag.

Encodes Boolean as a canonical single-byte flag.

Encoding:

  • false: 0x00
  • true: 0x01

Attributes

Source
ByteEncoder.scala
given byteEncoder: ByteEncoder[Byte]

Encodes Byte as single byte.

Encodes Byte as single byte.

Attributes

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

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

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

Encodes each field in order and concatenates the results.

Attributes

See also

types.md for product encoding details

Source
ByteEncoder.scala
given instantEncoder: ByteEncoder[Instant]

Encodes Instant as epoch milliseconds (Long encoding).

Encodes Instant as epoch milliseconds (Long encoding).

Attributes

See also

types.md for Instant encoding rules

Source
ByteEncoder.scala
given listByteEncoder[A : ByteEncoder]: ByteEncoder[List[A]]

Encodes List as [size:BigNat][elem1][elem2]...[elemN].

Encodes List as [size:BigNat][elem1][elem2]...[elemN].

Preserves order of elements.

Attributes

See also

types.md for List encoding rules

Source
ByteEncoder.scala
given longEncoder: ByteEncoder[Long]

Encodes Long as 8-byte big-endian representation.

Encodes Long as 8-byte big-endian representation.

Attributes

Source
ByteEncoder.scala
given mapByteEncoder[K : ByteEncoder, V : ByteEncoder]: ByteEncoder[Map[K, V]]

Encodes Map as deterministically sorted Set of tuples.

Encodes Map as deterministically sorted Set of tuples.

Converted to Set[(K, V)] and encoded with Set's deterministic ordering.

Attributes

See also

types.md for Map encoding rules

Source
ByteEncoder.scala
given optionByteEncoder[A : ByteEncoder]: ByteEncoder[Option[A]]

Encodes Option as zero or one-element List.

Encodes Option as zero or one-element List.

Encoding:

  • None: [0x00]
  • Some(x): [0x01][x encoded]

Attributes

See also

types.md for Option encoding rules

Source
ByteEncoder.scala
given setByteEncoder[A : ByteEncoder]: ByteEncoder[Set[A]]

Encodes Set with deterministic ordering.

Encodes Set with deterministic ordering.

Elements are encoded individually, then sorted lexicographically by their byte representation before concatenation. This ensures deterministic encoding regardless of Set iteration order.

Attributes

See also

types.md for Set encoding and sorting rules

Source
ByteEncoder.scala

Encodes Unit as empty byte sequence.

Encodes Unit as empty byte sequence.

Attributes

See also

types.md for Unit encoding rules

Source
ByteEncoder.scala