pub struct Memory { /* private fields */ }Expand description
Append-only causal memory.
This structure maintains a complete, immutable history of all events. History cannot be modified, deleted, or reset without terminating the lineage.
INVARIANT: Events form a strict causal chain with no gaps. INVARIANT: Once terminated, no further events can be appended.
Implementations§
Source§impl Memory
impl Memory
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new memory with genesis event.
The genesis event marks the beginning of this lineage’s history.
Sourcepub fn append(&mut self, description: String)
pub fn append(&mut self, description: String)
Appends a new event to the causal chain.
CONSEQUENCE: This event is now permanent and immutable. INVARIANT: Events must be appended in strict sequential order.
§Panics
Panics if memory has been terminated. This is an ontological violation.
Sourcepub fn history(&self) -> &[Event]
pub fn history(&self) -> &[Event]
Returns the complete, immutable event history.
This is read-only access to all events that have ever occurred.
Sourcepub fn event_count(&self) -> usize
pub fn event_count(&self) -> usize
Returns the total number of events in history.
Sourcepub fn is_terminated(&self) -> bool
pub fn is_terminated(&self) -> bool
Returns whether this memory has been terminated and sealed.
Once terminated, no further events can be appended.
Sourcepub fn terminate(&mut self, reason: String)
pub fn terminate(&mut self, reason: String)
Terminates and seals this memory ledger.
CONSEQUENCE: This is irreversible. No further events can be appended. CONSEQUENCE: This records the termination in the causal chain.
§Panics
Panics if already terminated.
Sourcepub fn verify_integrity(&self) -> bool
pub fn verify_integrity(&self) -> bool
Verifies the causal chain integrity.
Returns true if all events form a valid causal chain. If this returns false, the lineage is corrupted and must terminate.