Skip to main content

Checkpoint

Struct Checkpoint 

Source
pub struct Checkpoint<S> {
    pub id: String,
    pub state: S,
    pub uuid: Uuid,
    pub hash: Hash32,
    pub entries_processed: usize,
    pub context: FoldContext,
    pub fold_version: usize,
    pub created_at: DateTime<Utc>,
}
Expand description

Generic checkpoint envelope wrapping an arbitrary fold state snapshot.

Carries metadata (ID, timestamp, hash, fold version) alongside the serializable state so consumers can verify and load the correct snapshot.

Fields§

§id: String

Human-readable checkpoint identifier (e.g. "hnsw_idx:ckpt-1").

§state: S

The snapshot state captured at this checkpoint.

§uuid: Uuid

Unique identifier for this checkpoint instance.

§hash: Hash32

BLAKE3 content hash of the canonical JSON serialization of state.

Computed by CheckpointStore::save and verified by CheckpointStore::load. A mismatch returns FoldError::IntegrityMismatch.

§entries_processed: usize

Number of entries processed when this checkpoint was taken.

§context: FoldContext

Fold context at checkpoint time.

§fold_version: usize

Monotonically increasing fold schema version.

§created_at: DateTime<Utc>

Wall-clock time when this checkpoint was created.

Implementations§

Source§

impl<S: Serialize> Checkpoint<S>

Source

pub fn new( id: impl Into<String>, state: S, uuid: Uuid, entries_processed: usize, context: FoldContext, fold_version: usize, ) -> Result<Self, FoldError>

Create a new checkpoint, computing the BLAKE3 hash of the state.

Returns FoldError::Serialization if state cannot be serialized to JSON.

Source

pub fn with_hash( id: impl Into<String>, state: S, uuid: Uuid, hash: Hash32, entries_processed: usize, context: FoldContext, fold_version: usize, ) -> Self

Create a checkpoint with a pre-computed hash (for deserialization / testing).

Callers are responsible for ensuring hash is consistent with state. Prefer Checkpoint::new for production use.

Trait Implementations§

Source§

impl<S: Clone> Clone for Checkpoint<S>

Source§

fn clone(&self) -> Checkpoint<S>

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<S: Debug> Debug for Checkpoint<S>

Source§

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

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

impl<'de, S> Deserialize<'de> for Checkpoint<S>
where S: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<S> Serialize for Checkpoint<S>
where S: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Checkpoint<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for Checkpoint<S>
where S: RefUnwindSafe,

§

impl<S> Send for Checkpoint<S>
where S: Send,

§

impl<S> Sync for Checkpoint<S>
where S: Sync,

§

impl<S> Unpin for Checkpoint<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Checkpoint<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for Checkpoint<S>
where S: UnwindSafe,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,