given_Flat_Word64

scalus.cardano.ledger.Word64.given_Flat_Word64
object given_Flat_Word64 extends Flat[Word64]

Flat encoder/decoder for Word64 using variable-length encoding.

Attributes

Graph
Supertypes
trait Flat[Word64]
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

inline def bitSize(a: Word64): Int

Exact size of the encoding of a in bits. Callers use it to size the scalus.serialization.flat.EncoderState buffer, so it must never under-estimate.

Exact size of the encoding of a in bits. Callers use it to size the scalus.serialization.flat.EncoderState buffer, so it must never under-estimate.

Attributes

def decode(decode: DecoderState): Word64

Decodes like Plutus's dWord64: at most ten 7-bit groups, least significant first.

Decodes like Plutus's dWord64: at most ten 7-bit groups, least significant first.

The tenth group holds bit 63 only, so it must be 0 or 1 and must not continue. Anything else is a number above 2^64 - 1, which Plutus rejects (for example a constr tag of 2^64), so this throws rather than keep the low 64 bits.

Attributes

Throws
scalus.serialization.flat.FlatDecodingError

if the number does not fit in 64 bits

inline def encode(a: Word64, encode: EncoderState): Unit

Writes a into encode.

Writes a into encode.

The buffer does not grow, so it must already have room for bitSize bits. Failing that is a defect in this instance rather than a problem with a: an under-estimating bitSize overruns the buffer with an ArrayIndexOutOfBoundsException, and a negative size is rejected by scalus.serialization.flat.EncoderState with an IllegalArgumentException. Use [[FlatCodec.encodeA*]] to get the sizing right.

Attributes