MemoryCodec<T> class abstract interface

A translation layer that converts application types to and from the JSON-compatible formats stored in a MemoryEnvelope.

This interface decouples the high-level types used by a Cell from the low-level representation required by storage backends.

The contract

  1. Encoding: encode transforms T into a plain JSON structure (null, bool, num, String, List, or Map). A value the codec cannot represent throws MemoryNotSerializable.
  2. Decoding: decode reconstructs T from the stored payload with the stored version.
  3. Round trip: whatever encode writes, decode reads back. verifyOnWrite asserts the invariant in debug and tests.
  4. Error taxonomy: only FormatException, TypeError and MemoryCorrupt thrown by decode classify as MemoryCorrupt. Any other exception is a codec bug and propagates unchanged.
Implementers

Properties

acceptsNull → bool
Whether encode accepts a null domain value.
no setter
hashCode → int
The hash code for this object.
no setterinherited
name → String
The unique name of the codec, recorded in the envelope.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
version → int
The current version of this codec.
no setter

Methods

decode(Object? payload, {required int fromVersion}) → T
Decodes a stored payload back into T.
encode(T value) → Object?
Encodes a value to a JSON-compatible format.
migrate(Object? payload, int fromVersion) → T?
Migrates a payload written by an older codec version, when this codec knows how. Returning a non-null value marks the record touched so the migrated payload is written back.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Static Properties

verifyOnWrite ↔ bool
Debug assertion of the round-trip invariant.
getter/setter pair