pub struct RewindStore { /* private fields */ }Expand description
Session-scoped dirty path tracker + disk-backed rewind store.
Implementations§
Source§impl RewindStore
impl RewindStore
pub fn new( data_dir: impl AsRef<Path>, session_id: &str, project_root: impl AsRef<Path>, ) -> Self
pub fn root(&self) -> &Path
Sourcepub fn note_written_paths(&mut self, paths: impl IntoIterator<Item = PathBuf>)
pub fn note_written_paths(&mut self, paths: impl IntoIterator<Item = PathBuf>)
Mark absolute paths as dirty (session lifetime) and turn-written.
Sourcepub fn clear_turn_written(&mut self)
pub fn clear_turn_written(&mut self)
Clear per-turn write set (call after capturing a point / finishing turn).
Sourcepub fn is_dirty(&self, abs: &Path) -> bool
pub fn is_dirty(&self, abs: &Path) -> bool
Whether abs is already tracked as dirty for this session.
Sourcepub fn next_prompt_index(&self) -> usize
pub fn next_prompt_index(&self) -> usize
Count of user turns already recorded (for next prompt_index).
Sourcepub fn ensure_pre_write_capture(
&mut self,
paths: impl IntoIterator<Item = PathBuf>,
) -> Result<()>
pub fn ensure_pre_write_capture( &mut self, paths: impl IntoIterator<Item = PathBuf>, ) -> Result<()>
Before a write tool mutates disk: snapshot paths not yet in the dirty set into the latest rewind point so restore can undo first-touch edits.
Call this with absolute (or project-relative) paths while the file still has its pre-write content. Marks paths dirty + turn-written.
Sourcepub fn capture_point(
&mut self,
prompt_index: usize,
prompt_text: &str,
created_at: u64,
) -> Result<RewindPointMeta>
pub fn capture_point( &mut self, prompt_index: usize, prompt_text: &str, created_at: u64, ) -> Result<RewindPointMeta>
Capture pre-turn state for prompt_index and append to disk.
Sourcepub fn finalize_turn_created_paths(&mut self, prompt_index: usize) -> Result<()>
pub fn finalize_turn_created_paths(&mut self, prompt_index: usize) -> Result<()>
Finalize created_paths for the latest point (paths newly written this turn that did not exist in that point’s pre-snapshot as existing files).
pub fn load_points(&self) -> Vec<RewindPointMeta>
Sourcepub fn restore_to(&mut self, prompt_index: usize) -> RestoreSummary
pub fn restore_to(&mut self, prompt_index: usize) -> RestoreSummary
Restore filesystem to pre-turn state of prompt_index, then drop points ≥ index.
Also deletes files first created in turns ≥ prompt_index.
Trait Implementations§
Source§impl Clone for RewindStore
impl Clone for RewindStore
Auto Trait Implementations§
impl Freeze for RewindStore
impl RefUnwindSafe for RewindStore
impl Send for RewindStore
impl Sync for RewindStore
impl Unpin for RewindStore
impl UnsafeUnpin for RewindStore
impl UnwindSafe for RewindStore
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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