pub struct LocalFileExplorerIoWorker { /* private fields */ }Expand description
Owned request/response channels and worker thread for local listings.
Construction starts one thread and one [LocalFileProvider]. Dropping the
handle requests shutdown but does not join the thread; the thread also exits
when all request senders disconnect.
§Examples
use ailloli_ui_widgets::files::LocalFileExplorerIoWorker;
let worker = LocalFileExplorerIoWorker::new();
assert!(worker.try_recv_all().is_empty());Implementations§
Source§impl LocalFileExplorerIoWorker
impl LocalFileExplorerIoWorker
Sourcepub fn new() -> Self
pub fn new() -> Self
Starts a background local-provider request loop.
The channels are unbounded. This function returns immediately after spawning and does not perform filesystem I/O on the caller’s thread.
§Examples
use ailloli_ui_widgets::files::LocalFileExplorerIoWorker;
let worker = LocalFileExplorerIoWorker::new();
assert!(worker.try_recv_all().is_empty());Sourcepub fn request(&self, request: FileExplorerIoRequest) -> Result<(), String>
pub fn request(&self, request: FileExplorerIoRequest) -> Result<(), String>
Queues a request without waiting for filesystem completion.
§Errors
Returns the channel error as a string if the worker has disconnected. A successful send does not imply that a directory read will succeed.
§Examples
use ailloli_ui_widgets::files::{FileExplorerIoRequest, LocalFileExplorerIoWorker};
let worker = LocalFileExplorerIoWorker::new();
worker.request(FileExplorerIoRequest::Shutdown)?;Sourcepub fn try_recv_all(&self) -> Vec<FileExplorerIoResponse>
pub fn try_recv_all(&self) -> Vec<FileExplorerIoResponse>
Drains every response currently available without blocking.
Responses preserve completion order. An empty vector means no result is ready or the response channel disconnected; it is not an error signal.
§Examples
use ailloli_ui_widgets::files::LocalFileExplorerIoWorker;
let worker = LocalFileExplorerIoWorker::default();
let ready = worker.try_recv_all();
assert!(ready.is_empty());Trait Implementations§
Source§impl Default for LocalFileExplorerIoWorker
Starts a worker using Self::new.
impl Default for LocalFileExplorerIoWorker
Starts a worker using Self::new.