pub struct OperationEngine<F: Filesystem> { /* private fields */ }Implementations§
Source§impl<F: Filesystem> OperationEngine<F>
impl<F: Filesystem> OperationEngine<F>
pub fn new(fs: F) -> Self
pub fn exists(&self, path: &Path) -> bool
Sourcepub fn resolve_directory(
&self,
input: &str,
home: &Path,
) -> Result<PathBuf, OxiNavError>
pub fn resolve_directory( &self, input: &str, home: &Path, ) -> Result<PathBuf, OxiNavError>
Read at most max bytes from the start of path, for read-only
viewing. Like the mutating operations, the path is checked before the
filesystem is touched.
Resolve a user-typed directory path for a jump: expand a leading ~
against home, then require that it exists and is a directory.
Lives on the engine rather than in pane because the checks go
through the Filesystem trait, which is what makes them testable
without a real directory to point at.
pub fn read_capped( &self, path: &Path, max: usize, ) -> Result<Vec<u8>, OxiNavError>
pub fn execute(&self, op: &Operation) -> Result<(), OxiNavError>
Sourcepub fn execute_with_progress(
&self,
op: &Operation,
cancel: &AtomicBool,
on_progress: &mut dyn FnMut(Progress),
) -> Result<OperationOutcome, OxiNavError>
pub fn execute_with_progress( &self, op: &Operation, cancel: &AtomicBool, on_progress: &mut dyn FnMut(Progress), ) -> Result<OperationOutcome, OxiNavError>
Execute an operation while reporting incremental progress and honoring a cooperative cancel flag.
For batch operations (Copy/Move/Delete over a directory) the engine
drives the recursive walk itself, emitting one Progress per file
and polling cancel before each not-yet-started item. Totals are fixed
by a pre-walk before the first item is processed. Rename, CreateDir,
CreateFile and CreateSymlink are instantaneous, so they delegate to
execute and emit a single final tick.
On cancellation the already-processed items are left in place (no
rollback) and OperationOutcome::Cancelled is returned.
Sourcepub fn estimate_totals(&self, op: &Operation) -> (usize, u64)
pub fn estimate_totals(&self, op: &Operation) -> (usize, u64)
Estimate the (items, bytes) an operation will process, matching what
execute_with_progress counts. Lets a
caller pre-sum batch-wide totals before starting work.