pub struct FileHistory { /* private fields */ }Expand description
File version history tracker
Thread-safe storage for file snapshots. Each file maintains an ordered
list of versions. Old versions are evicted when max_snapshots is reached.
Implementations§
Source§impl FileHistory
impl FileHistory
Sourcepub fn new(max_snapshots: usize) -> Self
pub fn new(max_snapshots: usize) -> Self
Create a new file history tracker
max_snapshots limits the total number of snapshots stored.
When exceeded, the oldest snapshots (across all files) are evicted.
Sourcepub fn save_snapshot(&self, path: &str, content: &str, tool_name: &str) -> usize
pub fn save_snapshot(&self, path: &str, content: &str, tool_name: &str) -> usize
Save a snapshot of a file’s content before modification
Returns the version number assigned to this snapshot.
Sourcepub fn list_versions(&self, path: &str) -> Vec<VersionSummary>
pub fn list_versions(&self, path: &str) -> Vec<VersionSummary>
List all versions of a specific file
Sourcepub fn list_files(&self) -> Vec<(String, usize)>
pub fn list_files(&self) -> Vec<(String, usize)>
List all tracked files with their version counts
Sourcepub fn get_version(&self, path: &str, version: usize) -> Option<FileSnapshot>
pub fn get_version(&self, path: &str, version: usize) -> Option<FileSnapshot>
Get a specific version’s content
Sourcepub fn get_latest(&self, path: &str) -> Option<FileSnapshot>
pub fn get_latest(&self, path: &str) -> Option<FileSnapshot>
Get the latest version of a file
Sourcepub fn diff(
&self,
path: &str,
from_version: usize,
to_version: usize,
) -> Option<String>
pub fn diff( &self, path: &str, from_version: usize, to_version: usize, ) -> Option<String>
Generate a unified diff between two versions of a file
Returns None if either version doesn’t exist.
Sourcepub fn diff_with_current(
&self,
path: &str,
version: usize,
current_content: &str,
) -> Option<String>
pub fn diff_with_current( &self, path: &str, version: usize, current_content: &str, ) -> Option<String>
Generate a diff between a version and the current file content
Sourcepub fn total_snapshots(&self) -> usize
pub fn total_snapshots(&self) -> usize
Get the total number of snapshots across all files
Sourcepub fn clear_file(&self, path: &str)
pub fn clear_file(&self, path: &str)
Clear all history for a specific file
Auto Trait Implementations§
impl !Freeze for FileHistory
impl RefUnwindSafe for FileHistory
impl Send for FileHistory
impl Sync for FileHistory
impl Unpin for FileHistory
impl UnsafeUnpin for FileHistory
impl UnwindSafe for FileHistory
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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