pub struct LocalFileTreeSource { /* private fields */ }Expand description
Worker-owned local source with non-recursive native directory watches.
All methods are synchronous and the type is intended to stay on its single
runtime worker. Event sequences and watch generations start at one and
saturate at u64::MAX; a successful watch/unwatch increments generation.
§Examples
use ailloli_ui_fs::FileTreeSource;
use ailloli_ui_fs_local::LocalFileTreeSource;
let source = LocalFileTreeSource::new()?;
assert!(source.supports_native_watch());Implementations§
Source§impl LocalFileTreeSource
Construction and raw-event normalization operations.
impl LocalFileTreeSource
Construction and raw-event normalization operations.
Sourcepub fn with_max_watchers(max_watchers: usize) -> Result<Self, FileError>
pub fn with_max_watchers(max_watchers: usize) -> Result<Self, FileError>
Allocates a source with an explicit simultaneous-watch ceiling.
Zero disables watch registration. The value is not clamped and does not affect filesystem reads or mutations.
§Errors
Returns [FileError::Io] when the platform watcher cannot initialize.
§Examples
use ailloli_ui_fs_local::LocalFileTreeSource;
let _: LocalFileTreeSource = LocalFileTreeSource::with_max_watchers(8)?;Trait Implementations§
Source§impl FileTreeSource for LocalFileTreeSource
Adapts local I/O, stable identity, mutations, and native watch to the worker contract.
impl FileTreeSource for LocalFileTreeSource
Adapts local I/O, stable identity, mutations, and native watch to the worker contract.
Source§fn read_dir(&mut self, uri: &FileUri) -> Result<Vec<FileEntry>, FileError>
fn read_dir(&mut self, uri: &FileUri) -> Result<Vec<FileEntry>, FileError>
Delegates one sorted, non-recursive directory read to the local provider.
§Errors
Propagates the URI, directory iteration, and metadata errors documented
by LocalFileProvider::read_dir.
Source§fn identity(&mut self, uri: &FileUri) -> Result<Option<FileIdentity>, FileError>
fn identity(&mut self, uri: &FileUri) -> Result<Option<FileIdentity>, FileError>
Returns Unix device/inode identity or an unsupported error elsewhere.
§Errors
Returns [FileError::InvalidUri] for a non-local URI, a mapped metadata
error on Unix, or [FileError::Unsupported] on non-Unix targets.
Source§fn create_directory(&mut self, uri: &FileUri) -> Result<(), FileError>
fn create_directory(&mut self, uri: &FileUri) -> Result<(), FileError>
Creates one directory without recursively creating parents.
§Errors
Propagates the URI and host creation errors documented by
LocalFileProvider::create_dir.
Source§fn create_file(&mut self, uri: &FileUri) -> Result<(), FileError>
fn create_file(&mut self, uri: &FileUri) -> Result<(), FileError>
Creates or truncates an empty file.
§Errors
Propagates the URI and host write errors documented by
LocalFileProvider::write_file.
Source§fn move_entry(&mut self, from: &FileUri, to: &FileUri) -> Result<(), FileError>
fn move_entry(&mut self, from: &FileUri, to: &FileUri) -> Result<(), FileError>
Moves through the provider’s rename-only policy; no cross-device fallback exists.
§Errors
Propagates invalid local URIs and host rename failures from the provider.
Source§fn remove_entry(
&mut self,
uri: &FileUri,
recursive: bool,
) -> Result<(), FileError>
fn remove_entry( &mut self, uri: &FileUri, recursive: bool, ) -> Result<(), FileError>
Chooses recursive or single-entry removal exactly from recursive.
§Errors
Propagates invalid local URIs and host traversal/removal failures from the selected provider operation.
Source§fn watch_directory(&mut self, uri: &FileUri) -> Result<(), FileError>
fn watch_directory(&mut self, uri: &FileUri) -> Result<(), FileError>
Adds one idempotent non-recursive native directory watch.
A distinct watch at the configured ceiling returns FileError::Other.
Successful additions saturating-increment the watch generation.
§Errors
Returns [FileError::InvalidUri] for a non-local URI,
[FileError::Other] when the configured watcher ceiling is reached, or
[FileError::Io] when the native watcher rejects the path.
Source§fn unwatch_directory(&mut self, uri: &FileUri) -> Result<(), FileError>
fn unwatch_directory(&mut self, uri: &FileUri) -> Result<(), FileError>
Removes a known watch idempotently and increments generation on success.
Unknown paths return success without calling the native watcher.
§Errors
Returns [FileError::InvalidUri] for a non-local URI or [FileError::Io]
when the native watcher fails to remove a known path.
Source§fn poll_watch(&mut self, limit: usize) -> Result<Vec<WatchEvent>, FileError>
fn poll_watch(&mut self, limit: usize) -> Result<Vec<WatchEvent>, FileError>
Returns up to limit normalized events after the 50-millisecond debounce.
Zero returns immediately without draining the raw channel. Later events
remain pending; normalized overflow remains queued for future calls.
Exact (kind, uri, previous_uri) duplicates are removed within each
returned batch. A disconnected callback channel is an I/O error.
§Errors
Returns [FileError::Io] for a disconnected callback channel or native
watcher error, and [FileError::InvalidUri] when normalizing an event path.
Source§fn supports_native_watch(&self) -> bool
fn supports_native_watch(&self) -> bool
Always reports native non-recursive watch support.