#[non_exhaustive]pub struct SyncRecord {
pub path: PathBuf,
pub kind: SyncKind,
pub at: Barrier,
pub durable_len: Option<u64>,
pub snapshot: Option<PathBuf>,
}Expand description
One successful sync: this path reached stable storage, at this length, at this point in the ordering.
A SyncRecord is only ever created after the underlying sync call
returned Ok. That is the whole contract — a journal that records
attempts rather than successes would make every downstream verdict a lie.
let record = SyncRecord::new("/tmp/app.db", SyncKind::File, Barrier::new(1), Some(4096));
assert_eq!(record.durable_len, Some(4096));
assert_eq!(record.kind, SyncKind::File);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.path: PathBufThe synced path, canonicalised when the filesystem allowed it.
kind: SyncKindWhich sync call was made.
at: BarrierWhere this sync sits in the ordering.
durable_len: Option<u64>The file’s length at the moment the sync returned Ok, when it could
be observed. Bytes appended after this length are not durable, and
Tier::PowerCut truncates the captured copy to it.
snapshot: Option<PathBuf>A byte-for-byte copy of the file’s certified content, taken the instant
the sync returned Ok.
This is what makes tier 2 exact rather than optimistic. Without it, a
capture has to read the file’s current bytes, which silently credits
any in-place overwrite made after the sync — and an in-place rewrite
that was never re-synced is precisely what a checkpoint or a compaction
does. SyncJournal always takes one; a hand-written witness may not,
and the capture prints a note saying so.
Implementations§
Source§impl SyncRecord
impl SyncRecord
Sourcepub fn new(
path: impl Into<PathBuf>,
kind: SyncKind,
at: Barrier,
durable_len: Option<u64>,
) -> Self
pub fn new( path: impl Into<PathBuf>, kind: SyncKind, at: Barrier, durable_len: Option<u64>, ) -> Self
Build a record. Call this only after a sync returned Ok.
let r = SyncRecord::new("data.log", SyncKind::Data, Barrier::new(3), None);
assert_eq!(r.at.seq(), 3);Sourcepub fn with_snapshot(self, snapshot: impl Into<PathBuf>) -> Self
pub fn with_snapshot(self, snapshot: impl Into<PathBuf>) -> Self
Attach a content snapshot — a file holding exactly the bytes this sync
certified. See SyncRecord::snapshot.
let r = SyncRecord::new("app.db", SyncKind::File, Barrier::new(1), Some(9))
.with_snapshot("/tmp/snap/1");
assert!(r.snapshot.is_some());