pub enum FileWatcherState {
Idle,
Watching {
paths: Vec<PathBuf>,
},
Failed {
error: String,
},
}Expand description
Runtime state of the file watcher
§State Machine
┌─────┐
│ Idle │
└──┬──┘
│ watch() succeeds
▼
┌─────────┐
│ Watching │
└────┬────┘
│ fatal error
▼
┌─────────┐
│ Failed │────┐
└─────────┘ │
│ │ recover (unwatch + re-watch)
│ └─────────────────────┐
▼ ▼
(exit application) ┌─────┐
│ Idle │
└─────┘§States
-
Idle: Initial state after
FileWatcher::new(). The watcher is created but not watching any paths yet. -
Watching: Active state after successful
watch()call. The watcher monitors the configured paths and emits file change events. -
Failed: Error state if watcher initialization fails. This is typically due to OS limitations (e.g., reached maximum file descriptor limit). Recovery requires creating a new
FileWatcherinstance.
§Example
use dampen_dev::watcher::{FileWatcher, FileWatcherConfig};
use std::path::PathBuf;
let config = FileWatcherConfig::default();
let mut watcher = FileWatcher::new(config).expect("Failed to create watcher");
// State is now Idle
let path = PathBuf::from("src/ui");
watcher.watch(path).expect("Failed to watch");
// State is now Watching
// If fatal error occurs, state becomes Failed
// Recovery requires creating new watcherVariants§
Idle
Watcher is initialized but not started
Watching
Actively watching for changes
Failed
Error state (watcher failed to initialize)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileWatcherState
impl RefUnwindSafe for FileWatcherState
impl Send for FileWatcherState
impl Sync for FileWatcherState
impl Unpin for FileWatcherState
impl UnwindSafe for FileWatcherState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Turns some type into the initial state of some
Application.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more