FlatCodec

scalus.serialization.flat.FlatCodec
object FlatCodec

Java-facing facade over the flat codec, and the home of the scalar helper implementations — the top-level functions of this package (zigZag, word7Bytes, ...) delegate here.

A plain object without a companion class gets static forwarders in its mirror class, so Java calls FlatCodec.encodeLong(v) directly on every platform — no MODULE$, no summon. Signatures use only byte[]/primitive/String types plus explicit Flat instances (see Flats) so Java never has to name a Scala collection or summon a given.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
FlatCodec.type

Members list

Value members

Concrete methods

def byteAsBitString(b: Byte): String

Renders a byte as its 8-character binary string, e.g. 0x0b"00001011". Debug aid for EncoderState.toString/DecoderState.toString.

Renders a byte as its 8-character binary string, e.g. 0x0b"00001011". Debug aid for EncoderState.toString/DecoderState.toString.

Attributes

def decode[A](bytes: Array[Byte], fl: Flat[A]): A

Decodes a value with an explicit instance — Java cannot summon; get instances from Flats.

Decodes a value with an explicit instance — Java cannot summon; get instances from Flats.

Attributes

def decodeBytes(bytes: Array[Byte]): Array[Byte]
def decodeLong(bytes: Array[Byte]): Long
def decodeString(bytes: Array[Byte]): String
def encode[A](value: A, fl: Flat[A]): Array[Byte]

Encodes a value with an explicit instance — Java cannot summon; get instances from Flats.

Encodes a value with an explicit instance — Java cannot summon; get instances from Flats.

Attributes

def encodeBytes(v: Array[Byte]): Array[Byte]
def encodeLong(v: Long): Array[Byte]
def encodeString(v: String): Array[Byte]
def word7Bytes(n: Long): Array[Byte]

Encodes n (treated as an unsigned 64-bit value) as a variable-length byte array: 7 payload bits per byte, least-significant group first, high bit set on every byte except the last. This is the byte layout of flat's data NonEmptyList = Elem Word7 | Cons Word7 NonEmptyList.

Encodes n (treated as an unsigned 64-bit value) as a variable-length byte array: 7 payload bits per byte, least-significant group first, high bit set on every byte except the last. This is the byte layout of flat's data NonEmptyList = Elem Word7 | Cons Word7 NonEmptyList.

Attributes

def word7BytesCount(n: Long): Int

Number of bytes in the variable-length 7-bit encoding of n, treating n as an unsigned 64-bit value.

Number of bytes in the variable-length 7-bit encoding of n, treating n as an unsigned 64-bit value.

Attributes

def zagZig(u: Int): Int

Inverse of zigZag(x:Int)*.

Inverse of zigZag(x:Int)*.

Attributes

def zagZig(u: Long): Long

Inverse of zigZag(x:Long)*.

Inverse of zigZag(x:Long)*.

Attributes

def zigZag(x: Int): Int

ZigZag encoding: maps signed values to unsigned so small magnitudes of either sign get short varint encodings (0 → 0, -1 → 1, 1 → 2, -2 → 3, 2 → 4, ...). Total over the whole Int/Long range: the doubling overflow is intentional and is inverted by zagZig. https://gist.github.com/mfuerstenau/ba870a29e16536fdbaba

ZigZag encoding: maps signed values to unsigned so small magnitudes of either sign get short varint encodings (0 → 0, -1 → 1, 1 → 2, -2 → 3, 2 → 4, ...). Total over the whole Int/Long range: the doubling overflow is intentional and is inverted by zagZig. https://gist.github.com/mfuerstenau/ba870a29e16536fdbaba

Attributes

def zigZag(x: Long): Long

Attributes