BsatnDecoder class

Decodes BSATN (Binary Spacetime Algebraic Type Notation) format into Dart values

BSATN is SpacetimeDB's binary serialization format. Use this decoder to:

  • Parse incoming messages from SpacetimeDB
  • Decode table rows
  • Read reducer results

All integers are decoded from little-endian byte order.

Example:

final bytes = Uint8List.fromList([...]);
final decoder = BsatnDecoder(bytes);

// Decode primitive types
final text = decoder.readString();
final number = decoder.readU32();
final flag = decoder.readBool();

// Decode optional values
final maybeValue = decoder.readOption<String>(() => decoder.readString());

// Decode arrays
final numbers = decoder.readArray<int>(() => decoder.readU32());

Constructors

BsatnDecoder(Uint8List _bytes)

Properties

hashCode int
The hash code for this object.
no setterinherited
offset int
no setter
remaining int
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

hexDump(int length) String
Debug helper: Dump next N bytes as hex
hexDumpAll() String
Debug helper: Dump all remaining bytes as hex
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readArray<T>(T readItem()) List<T>
Decodes an array with length prefix
readBool() bool
Decodes a boolean value (0 = false, 1 = true)
readByteArray() List<int>
readBytes(int length) Uint8List
readF32() double
readF64() double
readI16() int
readI32() int
readI64() Int64
readI8() int
readIdentity() Identity
readList<T>(T readItem()) List<T>
readMap<K, V>(K readKey(), V readValue()) Map<K, V>
Decodes a map with length prefix
readOption<T>(T readValue()) → T?
Decodes an optional value
readString() String
Decodes a UTF-8 string with length prefix
readU16() int
readU32() int
Decodes an unsigned 32-bit integer from little-endian bytes
readU64() Int64
readU8() int
Decodes an unsigned 8-bit integer (0-255)
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited