read method
Reads the envelope stored under id, or null when absent or
expired (C1, C3).
Throws: MemoryCorrupt on unreadable or malformed data;
StateError after close.
Implementation
@override
Future<MemoryEnvelope?> read(String id) {
checkId(id);
return _lifecycle.run(() => _serializer.run(id, () async {
await _checkCaseCollision(id);
final file = _fileFor(id);
if (!await file.exists()) return null;
final envelope = await _readEnvelopeFile(file);
if (envelope == null) return null; // expired or unacknowledged tmp
if (envelope.id != id) {
throw MemoryCorrupt(
'envelope id "${envelope.id}" does not match file "$id"');
}
if (_isExpired(envelope)) return null;
return envelope;
}));
}