DiskPersistence class

Handles reading and writing .ttd session files to the local filesystem.

File layout (JSON):

{
  "ttdVersion": "1.0",
  "metadata": { ... },
  "snapshots": [ ... ],
  "records": [ ... ]
}

Large sessions are written in streaming mode (line-delimited JSON chunks) when streamingMode is enabled, which avoids peak memory spikes.

Constructors

DiskPersistence({required String sessionDirectory, bool streamingMode = false})

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sessionDirectory → String
Root directory for session files.
final
streamingMode → bool
Whether to write in streaming (line-delimited) mode.
final

Methods

deleteAllSessions() → Future<void>
deleteSession(String filePath) → Future<void>
ensureDirectory() → Future<void>
Ensures sessionDirectory exists.
listSessions() → Future<List<File>>
Returns all .ttd files in sessionDirectory, sorted newest-first.
loadSession(String filePath) → Future<LoadedSession>
Loads a session from filePath.
loadSnapshot(String snapshotPath) → Future<StateSnapshot>
Loads a single snapshot file (written by saveSnapshot).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
saveSession({required String filePath, required SessionMetadata metadata, required List<StateSnapshot> snapshots, required List<VariableRecord> records}) → Future<String>
Saves snapshots and records to filePath.
saveSnapshot({required String sessionId, required StateSnapshot snapshot}) → Future<void>
Saves a single StateSnapshot to its own compact file.
toString() → String
A string representation of this object.
inherited

Operators

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