pub struct FileHistory { /* private fields */ }Expand description
File history manager for one session.
Implementations§
Source§impl FileHistory
impl FileHistory
pub fn new(session_id: &str) -> Self
Sourcepub async fn backup_before_write(&mut self, file_path: &str) -> Option<u32>
pub async fn backup_before_write(&mut self, file_path: &str) -> Option<u32>
Backup a file before it gets modified. Call this BEFORE writing/editing. No-op if file doesn’t exist (new file). Returns the backup version number, or None if no backup was needed.
Sourcepub async fn restore(
&self,
file_path: &str,
version: Option<u32>,
) -> Result<u32, String>
pub async fn restore( &self, file_path: &str, version: Option<u32>, ) -> Result<u32, String>
Restore a file to a specific version. Returns Ok(version) on success, Err(message) on failure.
Sourcepub fn list_files(&self) -> Vec<(String, usize)>
pub fn list_files(&self) -> Vec<(String, usize)>
List all backed-up files and their version counts.
Sourcepub fn latest_version(&self, file_path: &str) -> Option<u32>
pub fn latest_version(&self, file_path: &str) -> Option<u32>
Get the most recently backed-up version number for a 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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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