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
- Encoding: encode transforms
Tinto a plain JSON structure (null, bool, num, String, List, or Map). A value the codec cannot represent throws MemoryNotSerializable. - Decoding: decode reconstructs
Tfrom the stored payload with the stored version. - Round trip: whatever encode writes, decode reads back. verifyOnWrite asserts the invariant in debug and tests.
- Error taxonomy: only
FormatException,TypeErrorandMemoryCorruptthrown 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