Skip to main content

ScanExecutor

Trait ScanExecutor 

Source
pub trait ScanExecutor: Send + Sync {
    // Required method
    fn spawn_blocking(
        &self,
        job: Box<dyn FnOnce() -> LoadPayload + Send>,
    ) -> Pin<Box<dyn Future<Output = LoadPayload> + Send>>;
}
Expand description

The executor seam — pluggable off-thread scan execution (S5.1).

Implement this trait to redirect scan work to a custom thread pool, tokio::task::spawn_blocking, smol, or any other executor. The default is ThreadExecutor.

§Object safety

The trait is object-safe; wrap in Arc<dyn ScanExecutor> to store it alongside a Signal<DirectoryTree>.

Required Methods§

Source

fn spawn_blocking( &self, job: Box<dyn FnOnce() -> LoadPayload + Send>, ) -> Pin<Box<dyn Future<Output = LoadPayload> + Send>>

Schedule job to run off the UI thread and return a future that resolves to its LoadPayload result.

The widget issues exactly one spawn_blocking call per crate::scan::ScanRequest (S5.2).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§