pub struct OpsManager {
source: PathBuf,
store: Option<Arc<dyn VectorStore>>,
reindex_sender: Option<Sender<PathBuf>>,
safety_manager: Option<Arc<SafetyManager>>,
last_result: Arc<RwLock<Option<OperationResult>>>,
last_batch_result: Arc<RwLock<Option<BatchResult>>>,
}Expand description
Operations manager for file operations with feedback.
Fields§
§source: PathBufSource directory root
store: Option<Arc<dyn VectorStore>>Vector store for indexing operations
reindex_sender: Option<Sender<PathBuf>>Channel to send reindex requests
safety_manager: Option<Arc<SafetyManager>>Safety manager for trash/history/undo (optional)
last_result: Arc<RwLock<Option<OperationResult>>>Last operation result (for .result file)
last_batch_result: Arc<RwLock<Option<BatchResult>>>Last batch result
Implementations§
Source§impl OpsManager
impl OpsManager
Sourcepub fn new(
source: PathBuf,
store: Option<Arc<dyn VectorStore>>,
reindex_sender: Option<Sender<PathBuf>>,
) -> Self
pub fn new( source: PathBuf, store: Option<Arc<dyn VectorStore>>, reindex_sender: Option<Sender<PathBuf>>, ) -> Self
Create a new operations manager.
Sourcepub fn with_safety(
source: PathBuf,
store: Option<Arc<dyn VectorStore>>,
reindex_sender: Option<Sender<PathBuf>>,
safety_manager: Arc<SafetyManager>,
) -> Self
pub fn with_safety( source: PathBuf, store: Option<Arc<dyn VectorStore>>, reindex_sender: Option<Sender<PathBuf>>, safety_manager: Arc<SafetyManager>, ) -> Self
Create operations manager with safety manager.
Sourcepub fn set_safety_manager(&mut self, safety_manager: Arc<SafetyManager>)
pub fn set_safety_manager(&mut self, safety_manager: Arc<SafetyManager>)
Set the safety manager.
Sourcefn log_to_history(
&self,
operation: HistoryOperation,
undo_data: Option<UndoData>,
)
fn log_to_history( &self, operation: HistoryOperation, undo_data: Option<UndoData>, )
Log operation to history if safety manager is available.
Sourcefn log_failure_to_history(&self, operation: HistoryOperation, error: &str)
fn log_failure_to_history(&self, operation: HistoryOperation, error: &str)
Log failure to history if safety manager is available.
Sourcefn resolve_path(&self, path: &PathBuf) -> PathBuf
fn resolve_path(&self, path: &PathBuf) -> PathBuf
Resolve a path relative to the source directory.
Sourceasync fn trigger_reindex(&self, path: &PathBuf) -> bool
async fn trigger_reindex(&self, path: &PathBuf) -> bool
Trigger reindexing for a path.
Sourceasync fn delete_from_store(&self, path: &PathBuf)
async fn delete_from_store(&self, path: &PathBuf)
Delete from vector store.
Sourceasync fn update_store_path(&self, from: &PathBuf, to: &PathBuf)
async fn update_store_path(&self, from: &PathBuf, to: &PathBuf)
Update path in vector store.
Sourceasync fn execute_with_rollback(
&self,
op: &Operation,
) -> (OperationResult, Option<RollbackData>)
async fn execute_with_rollback( &self, op: &Operation, ) -> (OperationResult, Option<RollbackData>)
Execute an operation and capture rollback data for atomic batches.
Returns (result, rollback_data) tuple.
Sourceasync fn rollback_operation(
&self,
rollback_data: &RollbackData,
) -> Result<(), String>
async fn rollback_operation( &self, rollback_data: &RollbackData, ) -> Result<(), String>
Rollback a single operation.
Sourceasync fn perform_rollback(&self, journal: &[JournalEntry]) -> RollbackDetails
async fn perform_rollback(&self, journal: &[JournalEntry]) -> RollbackDetails
Perform rollback of journal entries in reverse order.
Sourcepub async fn create(&self, path: &PathBuf, content: &str) -> OperationResult
pub async fn create(&self, path: &PathBuf, content: &str) -> OperationResult
Create a new file with content.
Sourcepub async fn delete(&self, path: &PathBuf) -> OperationResult
pub async fn delete(&self, path: &PathBuf) -> OperationResult
Delete a file. Uses soft delete (move to trash) if safety manager is available.
Sourcepub async fn move_file(&self, src: &PathBuf, dst: &PathBuf) -> OperationResult
pub async fn move_file(&self, src: &PathBuf, dst: &PathBuf) -> OperationResult
Move/rename a file.
Sourcepub async fn copy(&self, src: &PathBuf, dst: &PathBuf) -> OperationResult
pub async fn copy(&self, src: &PathBuf, dst: &PathBuf) -> OperationResult
Copy a file.
Sourcepub async fn write(
&self,
path: &PathBuf,
content: &str,
append: bool,
) -> OperationResult
pub async fn write( &self, path: &PathBuf, content: &str, append: bool, ) -> OperationResult
Write content to a file.
Sourcepub async fn mkdir(&self, path: &PathBuf) -> OperationResult
pub async fn mkdir(&self, path: &PathBuf) -> OperationResult
Create a directory.
Sourcepub async fn symlink(&self, target: &PathBuf, link: &PathBuf) -> OperationResult
pub async fn symlink(&self, target: &PathBuf, link: &PathBuf) -> OperationResult
Create a symbolic link.
Sourcepub async fn execute_operation(&self, op: &Operation) -> OperationResult
pub async fn execute_operation(&self, op: &Operation) -> OperationResult
Execute a single operation.
Sourcepub async fn batch(&self, request: BatchRequest) -> BatchResult
pub async fn batch(&self, request: BatchRequest) -> BatchResult
Execute a batch of operations.
Sourcefn validate_operation(&self, op: &Operation) -> OperationResult
fn validate_operation(&self, op: &Operation) -> OperationResult
Validate an operation without executing it.
Sourcepub async fn get_last_result(&self) -> Vec<u8> ⓘ
pub async fn get_last_result(&self) -> Vec<u8> ⓘ
Get the last operation result as JSON.
Sourcepub async fn get_last_batch_result(&self) -> Vec<u8> ⓘ
pub async fn get_last_batch_result(&self) -> Vec<u8> ⓘ
Get the last batch result as JSON.
Sourcepub async fn parse_and_create(&self, input: &str) -> OperationResult
pub async fn parse_and_create(&self, input: &str) -> OperationResult
Parse and execute a create operation from string input. Format: “path\ncontent”
Sourcepub async fn parse_and_delete(&self, input: &str) -> OperationResult
pub async fn parse_and_delete(&self, input: &str) -> OperationResult
Parse and execute a delete operation from string input. Format: “path”
Sourcepub async fn parse_and_move(&self, input: &str) -> OperationResult
pub async fn parse_and_move(&self, input: &str) -> OperationResult
Parse and execute a move operation from string input. Format: “src\ndst”
Sourcepub async fn parse_and_batch(&self, input: &str) -> BatchResult
pub async fn parse_and_batch(&self, input: &str) -> BatchResult
Parse and execute a batch operation from JSON input.