pub struct CheckpointStore { /* private fields */ }Expand description
Workspace-wide, per-session checkpoint store.
Partitioned by session (issue #14): two OpenCode sessions sharing one bridge
can both create checkpoints named snap1 without collision, and restoring
from one session does not leak the other’s file set. Checkpoints are kept
in memory only — a bridge crash drops all of them, which is a deliberate
trade-off to keep this refactor bounded. Durable checkpoints are a possible
follow-up.
Implementations§
Source§impl CheckpointStore
impl CheckpointStore
pub fn new() -> Self
Sourcepub fn create(
&mut self,
session: &str,
name: &str,
files: Vec<PathBuf>,
backup_store: &BackupStore,
) -> Result<CheckpointInfo, AftError>
pub fn create( &mut self, session: &str, name: &str, files: Vec<PathBuf>, backup_store: &BackupStore, ) -> Result<CheckpointInfo, AftError>
Create a checkpoint by reading the given files, scoped to session.
If files is empty, snapshots all tracked files for that session
from the BackupStore (other sessions’ tracked files are not visible).
Overwrites any existing checkpoint with the same name in this session.
Unreadable paths (e.g. deleted since their last edit) are skipped with
a warning instead of failing the whole checkpoint. The paths and their
errors are returned via CheckpointInfo::skipped so callers can
surface them. A checkpoint is only rejected outright when every
requested path fails — that case still returns a FileNotFound
error so callers can distinguish “partial success” from “nothing
snapshotted at all”.
Sourcepub fn restore(
&self,
session: &str,
name: &str,
) -> Result<CheckpointInfo, AftError>
pub fn restore( &self, session: &str, name: &str, ) -> Result<CheckpointInfo, AftError>
Restore a checkpoint by overwriting files with stored content.
Sourcepub fn restore_validated(
&self,
session: &str,
name: &str,
validated_paths: &[PathBuf],
) -> Result<CheckpointInfo, AftError>
pub fn restore_validated( &self, session: &str, name: &str, validated_paths: &[PathBuf], ) -> Result<CheckpointInfo, AftError>
Restore a checkpoint using a caller-validated path list.
Sourcepub fn file_paths(
&self,
session: &str,
name: &str,
) -> Result<Vec<PathBuf>, AftError>
pub fn file_paths( &self, session: &str, name: &str, ) -> Result<Vec<PathBuf>, AftError>
Return the file paths stored for a checkpoint.
Sourcepub fn delete(&mut self, session: &str, name: &str) -> bool
pub fn delete(&mut self, session: &str, name: &str) -> bool
Delete a checkpoint from a session. Returns true when a checkpoint was removed.
Sourcepub fn list(&self, session: &str) -> Vec<CheckpointInfo>
pub fn list(&self, session: &str) -> Vec<CheckpointInfo>
List all checkpoints for this session with metadata.
Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
Total checkpoint count across all sessions (for /aft-status).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CheckpointStore
impl RefUnwindSafe for CheckpointStore
impl Send for CheckpointStore
impl Sync for CheckpointStore
impl Unpin for CheckpointStore
impl UnsafeUnpin for CheckpointStore
impl UnwindSafe for CheckpointStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more