scalus.serialization.flat

Members list

Type members

Classlikes

class ArrayByteFlat extends Flat[Array[Byte]]

Prealigned Arrays of bytes PreAligned a ≡ PreAligned {preFiller :: Filler, preValue :: a}

Prealigned Arrays of bytes PreAligned a ≡ PreAligned {preFiller :: Filler, preValue :: a}

Filler ≡ FillerBit Filler | FillerEnd

Array v = A0 | A1 v (Array v) | A2 v v (Array v) ... | A255 ... (Array v)

Attributes

Supertypes
trait Flat[Array[Byte]]
class Object
trait Matchable
class Any

Flat serialization instance for Data type.

Flat serialization instance for Data type.

This is kept separate from FlatInstances.scala because Data uses scalus.cardano.onchain.plutus.prelude.List, which is not available in the compiler plugin. The compiler plugin doesn't need to serialize Data values directly - it only needs the SIR/SIRType serialization from FlatInstances.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
class DecoderState(val buffer: Uint8Array)

Mutable bit-level cursor over a flat-encoded byte array. Mirrors EncoderState: bits are read most-significant first within each byte.

Mutable bit-level cursor over a flat-encoded byte array. Mirrors EncoderState: bits are read most-significant first within each byte.

Attributes

Supertypes
class Object
trait Matchable
class Any
class EncoderState(bufferSize: Int)

Mutable bit-level output buffer for flat encoding. Bits are accumulated into currentByte (most-significant first) and flushed to buffer one byte at a time. The caller must pre-size bufferSize from Flat.bitSize — the buffer does not grow.

Mutable bit-level output buffer for flat encoding. Bits are accumulated into currentByte (most-significant first) and flushed to buffer one byte at a time. The caller must pre-size bufferSize from Flat.bitSize — the buffer does not grow.

Attributes

Supertypes
class Object
trait Matchable
class Any
trait Flat[A]

Type class for the flat binary encoding (a bit-oriented serialization format, see https://hackage.haskell.org/package/flat and the Plutus Core specification, Appendix D). UPLC programs and SIR modules are serialized with instances of this trait.

Type class for the flat binary encoding (a bit-oriented serialization format, see https://hackage.haskell.org/package/flat and the Plutus Core specification, Appendix D). UPLC programs and SIR modules are serialized with instances of this trait.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
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.

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

Supertypes
class Object
trait Matchable
class Any
Self type
FlatCodec.type
object FlatInstances

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Flats

Named accessors for the primitive Flat instances, since Java cannot summon.

Named accessors for the primitive Flat instances, since Java cannot summon.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Flats.type
object HashConsed

Objects are hash-consed during restoring from file. Note, that identityHashCode can be different on the different VM-s, so it is not safe to reky on it. value-based hash-code now is not determenistics on recuresive data structures with self-references. So, we use identityHashCode on VN which store file and restore internal references on other VN.

Objects are hash-consed during restoring from file. Note, that identityHashCode can be different on the different VM-s, so it is not safe to reky on it. value-based hash-code now is not determenistics on recuresive data structures with self-references. So, we use identityHashCode on VN which store file and restore internal references on other VN.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
HashConsed.type
class HashConsedDecoderState(val decode: DecoderState, val hashConsed: State, val debug: Boolean = ...)

Attributes

Supertypes
class Object
trait Matchable
class Any
class HashConsedEncoderState(val encode: EncoderState, val hashConsed: State, val debug: Boolean = ...)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
trait HashConsedFlat[A] extends Flat[A]

Attributes

Companion
object
Supertypes
trait Flat[A]
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait HashConsedMutRefReprFlat[A <: AnyRef, SA <: HashConsedRef[A]] extends HashConsedReprFlat[A, SA]

Attributes

Supertypes
trait HashConsedReprFlat[A, SA]
class Object
trait Matchable
class Any
Known subtypes
trait HashConsedRef[+A <: AnyRef]

When we read from the HashConsedRead.State, we can have forward references, which will be resolved after the whole structure is readed. Here, HashConsedRef can hold object ro Ref or object of some intermediate representation, which holds other refs.

When we read from the HashConsedRead.State, we can have forward references, which will be resolved after the whole structure is readed. Here, HashConsedRef can hold object ro Ref or object of some intermediate representation, which holds other refs.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class CachedTaggedRef[A]
class ConstRef[A]
class ForwardRef[A]
class MutRef[A]
class ListRepl[A, SA]
class StringMapRep[A, SA]
Show all
object HashConsedRef

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait HashConsedReprFlat[A <: AnyRef, SA <: HashConsedRef[A]]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
case class Natural(n: BigInt)

A non-negative integer, encoded as an unsigned varint (no zigzag), matching flat's Natural.

A non-negative integer, encoded as an unsigned varint (no zigzag), matching flat's Natural.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object PlainIntFlat extends HashConsedFlat[Int]

Attributes

Supertypes
trait HashConsedFlat[Int]
trait Flat[Int]
class Object
trait Matchable
class Any
Self type
object given_Flat_BigInt extends Flat[BigInt]

Attributes

Supertypes
trait Flat[BigInt]
class Object
trait Matchable
class Any
Self type
object given_Flat_Boolean extends Flat[Boolean]

Attributes

Supertypes
trait Flat[Boolean]
class Object
trait Matchable
class Any
Self type
object given_Flat_Int extends Flat[Int]

Attributes

Supertypes
trait Flat[Int]
class Object
trait Matchable
class Any
Self type
object given_Flat_Long extends Flat[Long]

Attributes

Supertypes
trait Flat[Long]
class Object
trait Matchable
class Any
Self type
object given_Flat_Natural extends Flat[Natural]

Attributes

Supertypes
trait Flat[Natural]
class Object
trait Matchable
class Any
Self type
object given_Flat_String extends Flat[String]

Attributes

Supertypes
trait Flat[String]
class Object
trait Matchable
class Any
Self type
object given_Flat_Unit extends Flat[Unit]

Attributes

Supertypes
trait Flat[Unit]
class Object
trait Matchable
class Any
Self type

Types

type HSRIdentityHashMap = IdentityHashMap[HashConsedRef[_], HashConsedRef[_]]
type Uint8Array = Array[Byte]

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 : Flat](dec: DecoderState): A
def encode[A : Flat](a: A, enc: EncoderState): Unit
def iterableFlat[A : Flat, C <: Iterable[A]](factory: Factory[A, C]): Flat[C]

Flat encoding for collections as flat lists: each element is prefixed by a 1 bit, terminated by a 0 bit (List a = Nil | Cons a (List a) with one tag bit per node).

Flat encoding for collections as flat lists: each element is prefixed by a 1 bit, terminated by a 0 bit (List a = Nil | Cons a (List a) with one tag bit per node).

Attributes

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

Extensions

Extensions

extension (s: State)
def allocKey(a: AnyRef, tag: Tag): Int
def finishCallbacks(debug: Boolean = ...): Unit
def lookup(ihc: Int, tag: Tag): Option[Either[ForwardRefAcceptor, HashConsedRef[_]]]
def lookupValue(ihc: Int, tag: Tag): Option[HashConsedRef[_]]
def putForwardRef(ihc: Int, tag: Tag, action: AnyRef => Unit): Unit
def putForwardValueAcceptor[A <: AnyRef](ihc: Int, tag: Tag, acceptor: A => Unit): Unit
def setRef[A <: AnyRef](ihc: Int, tag: Tag, a: HashConsedRef[A]): Unit