pub trait PreWriteHook {
// Required method
fn before_write(
&mut self,
cell: StateCellId,
loc: SlotLocation,
old: &FourStateValue,
new_incoming: &FourStateValue,
at: SimTime,
);
}Expand description
The ST-091/ST-031 “hook present in the calling convention from the first
freeze” requirement made concrete now: commit_write takes hook: &mut dyn PreWriteHook as a required parameter, not an optional add-on, so a
later real undo-log PreWriteHook implementer slots in without touching
this signature or any of its call sites.
Deviation from the plan’s literal signature (binding per this task’s
own unresolved-review-findings list): before_write also receives
cell: StateCellId, not just loc/old/new_incoming — commit_write
already has cell in scope at the call site, and a later undo-log
implementer needs the StateCellId (not merely a SlotLocation) to
replay a rollback via commit_write_no_hook(cell, ...); no
SlotLocation -> StateCellId reverse lookup exists anywhere in this
crate, so cell must be threaded through here directly.
Second deviation (Task 16): before_write also receives
at: SimTime. Task 16’s UndoLog (state::rollback) implements this
trait and must tag every entry it records with the SimTime the write
happened at — fossil_collect(gvt)’s own acceptance text (“trims entries
the caller asserts are provably before gvt”) is only meaningful if the
log’s entries actually carry a timestamp to compare against gvt, and
nothing else in this calling convention threads one to the hook. The one
call site (commit_write_at, below) already reads vc.current_time()
for its own VcRecord.at field, so passing that same value to the hook
costs nothing extra and keeps both timestamps (the VC record’s and the
undo entry’s) identically sourced.
Required Methods§
fn before_write( &mut self, cell: StateCellId, loc: SlotLocation, old: &FourStateValue, new_incoming: &FourStateValue, at: SimTime, )
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl PreWriteHook for ()
The no-op default: v1 (LOOKAHEAD_CYCLES = 0) never exercises rollback,
so every call site that doesn’t care passes &mut ().
impl PreWriteHook for ()
The no-op default: v1 (LOOKAHEAD_CYCLES = 0) never exercises rollback,
so every call site that doesn’t care passes &mut ().