pub fn compensating_event(
original: &Event,
prior_events: &[&Event],
current_agent: &str,
now: i64,
) -> Result<Event, UndoError>Expand description
Generate a compensating event that reverses the effect of original.
prior_events must be all events for the same item that occurred
before original, sorted in ascending chronological order. This
context is required for:
item.move— to find the prior lifecycle stateitem.update— to find the prior field valueitem.delete— to reconstruct the originalitem.createdata
The returned event has event_hash set to an empty string; callers are
responsible for calling crate::event::writer::write_event to compute
and fill the hash before appending to the shard.
§Errors
UndoError::GrowOnly— foritem.comment,item.compact,item.snapshot, anditem.redact.UndoError::NoPriorState— when prior event context is needed but cannot be found (e.g. undoitem.deletewith no prioritem.create).