pub struct ConfigWatcher<T: HotConfig> { /* private fields */ }Expand description
Configuration watcher that automatically reloads config on file changes
Features:
- Automatic reload on file changes
- Debouncing to prevent excessive reloads
- Validation before applying
- Atomic updates with arc-swap
- Error recovery (keeps previous config on failure)
Implementations§
Source§impl<T: HotConfig> ConfigWatcher<T>
impl<T: HotConfig> ConfigWatcher<T>
Sourcepub fn new<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn new<P: AsRef<Path>>(path: P) -> Result<Self>
Create a new config watcher with default debounce duration (500ms)
Sourcepub fn with_debounce<P: AsRef<Path>>(
path: P,
debounce: Duration,
) -> Result<Self>
pub fn with_debounce<P: AsRef<Path>>( path: P, debounce: Duration, ) -> Result<Self>
Create a new config watcher with custom debounce duration
Debouncing prevents excessive reloads when a file is modified multiple times in quick succession (common with text editors).
pub fn path(&self) -> &Path
Sourcepub fn debounce_duration(&self) -> Duration
pub fn debounce_duration(&self) -> Duration
Get the debounce duration
Sourcepub fn time_since_last_reload(&self) -> Duration
pub fn time_since_last_reload(&self) -> Duration
Get the time since last reload
Auto Trait Implementations§
impl<T> Freeze for ConfigWatcher<T>
impl<T> RefUnwindSafe for ConfigWatcher<T>where
T: RefUnwindSafe,
impl<T> Send for ConfigWatcher<T>
impl<T> Sync for ConfigWatcher<T>
impl<T> Unpin for ConfigWatcher<T>
impl<T> UnwindSafe for ConfigWatcher<T>where
T: RefUnwindSafe,
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