Skip to main content

OperationEngine

Struct OperationEngine 

Source
pub struct OperationEngine<F: Filesystem> { /* private fields */ }

Implementations§

Source§

impl<F: Filesystem> OperationEngine<F>

Source

pub fn new(fs: F) -> Self

Source

pub fn exists(&self, path: &Path) -> bool

Source

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.

Source

pub fn read_capped( &self, path: &Path, max: usize, ) -> Result<Vec<u8>, OxiNavError>

Source

pub fn execute(&self, op: &Operation) -> Result<(), OxiNavError>

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<F> Freeze for OperationEngine<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for OperationEngine<F>
where F: RefUnwindSafe,

§

impl<F> Send for OperationEngine<F>

§

impl<F> Sync for OperationEngine<F>

§

impl<F> Unpin for OperationEngine<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for OperationEngine<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for OperationEngine<F>
where F: UnwindSafe,

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.

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.