Struct LocalFileTreeSource

Source
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.

Source

pub fn new() -> Result<Self, FileError>

Allocates a source with the default 1,024-watcher ceiling.

§Errors

Returns [FileError::Io] when the platform watcher cannot initialize.

§Examples
use ailloli_ui_fs_local::LocalFileTreeSource;
let _: LocalFileTreeSource = LocalFileTreeSource::new()?;
Source

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.

Source§

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>

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>

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>

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>

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>

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>

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>

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>

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

Always reports native non-recursive watch support.

Auto Trait Implementations§

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.