OpsManager

Struct OpsManager 

Source
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: PathBuf

Source 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

Source

pub fn new( source: PathBuf, store: Option<Arc<dyn VectorStore>>, reindex_sender: Option<Sender<PathBuf>>, ) -> Self

Create a new operations manager.

Source

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.

Source

pub fn set_safety_manager(&mut self, safety_manager: Arc<SafetyManager>)

Set the safety manager.

Source

fn log_to_history( &self, operation: HistoryOperation, undo_data: Option<UndoData>, )

Log operation to history if safety manager is available.

Source

fn log_failure_to_history(&self, operation: HistoryOperation, error: &str)

Log failure to history if safety manager is available.

Source

fn resolve_path(&self, path: &PathBuf) -> PathBuf

Resolve a path relative to the source directory.

Source

async fn trigger_reindex(&self, path: &PathBuf) -> bool

Trigger reindexing for a path.

Source

async fn delete_from_store(&self, path: &PathBuf)

Delete from vector store.

Source

async fn update_store_path(&self, from: &PathBuf, to: &PathBuf)

Update path in vector store.

Source

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.

Source

async fn rollback_operation( &self, rollback_data: &RollbackData, ) -> Result<(), String>

Rollback a single operation.

Source

async fn perform_rollback(&self, journal: &[JournalEntry]) -> RollbackDetails

Perform rollback of journal entries in reverse order.

Source

pub async fn create(&self, path: &PathBuf, content: &str) -> OperationResult

Create a new file with content.

Source

pub async fn delete(&self, path: &PathBuf) -> OperationResult

Delete a file. Uses soft delete (move to trash) if safety manager is available.

Source

pub async fn move_file(&self, src: &PathBuf, dst: &PathBuf) -> OperationResult

Move/rename a file.

Source

pub async fn copy(&self, src: &PathBuf, dst: &PathBuf) -> OperationResult

Copy a file.

Source

pub async fn write( &self, path: &PathBuf, content: &str, append: bool, ) -> OperationResult

Write content to a file.

Source

pub async fn mkdir(&self, path: &PathBuf) -> OperationResult

Create a directory.

Create a symbolic link.

Source

pub async fn execute_operation(&self, op: &Operation) -> OperationResult

Execute a single operation.

Source

pub async fn batch(&self, request: BatchRequest) -> BatchResult

Execute a batch of operations.

Source

fn validate_operation(&self, op: &Operation) -> OperationResult

Validate an operation without executing it.

Source

pub async fn get_last_result(&self) -> Vec<u8>

Get the last operation result as JSON.

Source

pub async fn get_last_batch_result(&self) -> Vec<u8>

Get the last batch result as JSON.

Source

pub async fn parse_and_create(&self, input: &str) -> OperationResult

Parse and execute a create operation from string input. Format: “path\ncontent”

Source

pub async fn parse_and_delete(&self, input: &str) -> OperationResult

Parse and execute a delete operation from string input. Format: “path”

Source

pub async fn parse_and_move(&self, input: &str) -> OperationResult

Parse and execute a move operation from string input. Format: “src\ndst”

Source

pub async fn parse_and_batch(&self, input: &str) -> BatchResult

Parse and execute a batch operation from JSON input.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more