pub struct SafetyManager {
config: SafetyConfig,
index_hash: String,
trash_dir: PathBuf,
history_file: PathBuf,
trash_cache: Arc<RwLock<Vec<TrashEntry>>>,
}Expand description
Safety manager for protecting file operations.
Fields§
§config: SafetyConfigConfiguration
index_hash: StringIndex hash (used for separating trash/history by index)
trash_dir: PathBufTrash directory
history_file: PathBufHistory file
trash_cache: Arc<RwLock<Vec<TrashEntry>>>In-memory cache of trash entries
Implementations§
Source§impl SafetyManager
impl SafetyManager
Sourcepub fn new(source: &PathBuf, config: Option<SafetyConfig>) -> Self
pub fn new(source: &PathBuf, config: Option<SafetyConfig>) -> Self
Create a new safety manager.
Sourcepub fn index_hash(&self) -> &str
pub fn index_hash(&self) -> &str
Get the index hash.
Sourcefn load_trash_entries(trash_dir: &PathBuf) -> Result<Vec<TrashEntry>>
fn load_trash_entries(trash_dir: &PathBuf) -> Result<Vec<TrashEntry>>
Load trash entries from disk.
Sourceasync fn save_trash_entries(&self) -> Result<()>
async fn save_trash_entries(&self) -> Result<()>
Save trash entries to disk.
Sourcepub async fn soft_delete(&self, path: &PathBuf) -> Result<TrashEntry, String>
pub async fn soft_delete(&self, path: &PathBuf) -> Result<TrashEntry, String>
Move a file to trash (soft delete).
Sourcepub async fn restore(&self, trash_id: Uuid) -> Result<PathBuf, String>
pub async fn restore(&self, trash_id: Uuid) -> Result<PathBuf, String>
Restore a file from trash.
Sourcepub async fn list_trash(&self) -> Vec<TrashEntry>
pub async fn list_trash(&self) -> Vec<TrashEntry>
List all trash entries.
Sourcepub async fn get_trash_entry(&self, id: Uuid) -> Option<TrashEntry>
pub async fn get_trash_entry(&self, id: Uuid) -> Option<TrashEntry>
Get a specific trash entry.
Sourcepub async fn purge_expired(&self) -> usize
pub async fn purge_expired(&self) -> usize
Purge expired trash entries.
Sourcepub fn log(&self, entry: HistoryEntry) -> Result<()>
pub fn log(&self, entry: HistoryEntry) -> Result<()>
Log an operation to history.
Sourcepub fn log_success(
&self,
operation: HistoryOperation,
undo_data: Option<UndoData>,
)
pub fn log_success( &self, operation: HistoryOperation, undo_data: Option<UndoData>, )
Log a successful operation.
Sourcepub fn log_failure(&self, operation: HistoryOperation, error: String)
pub fn log_failure(&self, operation: HistoryOperation, error: String)
Log a failed operation.
Sourcepub fn read_history(&self, limit: Option<usize>) -> Vec<HistoryEntry>
pub fn read_history(&self, limit: Option<usize>) -> Vec<HistoryEntry>
Read history entries.
Sourcepub fn get_history_json(&self, limit: Option<usize>) -> Vec<u8> ⓘ
pub fn get_history_json(&self, limit: Option<usize>) -> Vec<u8> ⓘ
Get history as JSON bytes (for FUSE read).
Sourcepub fn find_operation(&self, id: Uuid) -> Option<HistoryEntry>
pub fn find_operation(&self, id: Uuid) -> Option<HistoryEntry>
Find an operation by ID for undo.
Sourcepub fn soft_delete_enabled(&self) -> bool
pub fn soft_delete_enabled(&self) -> bool
Check if soft delete is enabled.
Auto Trait Implementations§
impl Freeze for SafetyManager
impl !RefUnwindSafe for SafetyManager
impl Send for SafetyManager
impl Sync for SafetyManager
impl Unpin for SafetyManager
impl !UnwindSafe for SafetyManager
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