Skip to main content

SyncRecord

Struct SyncRecord 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§path: PathBuf

The synced path, canonicalised when the filesystem allowed it.

§kind: SyncKind

Which sync call was made.

§at: Barrier

Where 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

Source

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);
Source

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());

Trait Implementations§

Source§

impl Clone for SyncRecord

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SyncRecord

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SyncRecord

Source§

impl PartialEq for SyncRecord

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SyncRecord

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.