pub struct ConfigWatcher { /* private fields */ }Expand description
Configuration watcher for hot reload support.
This struct manages configuration file watching and event distribution. The actual file system watching should be implemented at the application level using this struct to distribute events.
Implementations§
Source§impl ConfigWatcher
impl ConfigWatcher
Sourcepub fn new() -> ConfigWatcher
pub fn new() -> ConfigWatcher
Create a new configuration watcher.
Sourcepub fn with_debounce(debounce_ms: u64) -> ConfigWatcher
pub fn with_debounce(debounce_ms: u64) -> ConfigWatcher
Create a new configuration watcher with custom debounce duration.
Sourcepub fn state(&self) -> WatcherState
pub fn state(&self) -> WatcherState
Get the current state.
Sourcepub fn register(&self, source: ConfigSource)
pub fn register(&self, source: ConfigSource)
Register a configuration source to watch.
Sourcepub fn unregister(&self, path: &PathBuf)
pub fn unregister(&self, path: &PathBuf)
Unregister a configuration source.
Sourcepub fn sources(&self) -> Vec<ConfigSource>
pub fn sources(&self) -> Vec<ConfigSource>
Get all registered sources.
Sourcepub fn subscribe(&self) -> Receiver<ConfigEvent>
pub fn subscribe(&self) -> Receiver<ConfigEvent>
Subscribe to configuration events.
Sourcepub fn emit(&self, event: ConfigEvent)
pub fn emit(&self, event: ConfigEvent)
Emit a configuration event.
This method should be called by the file system watcher implementation. Events are debounced based on the configured duration.
Sourcepub fn emit_modified(&self, source: ConfigSource)
pub fn emit_modified(&self, source: ConfigSource)
Emit a modification event for a source.
Sourcepub fn emit_reloaded(&self, source: ConfigSource)
pub fn emit_reloaded(&self, source: ConfigSource)
Emit a reload success event.
Sourcepub fn emit_error(
&self,
source: Option<ConfigSource>,
message: impl Into<String>,
)
pub fn emit_error( &self, source: Option<ConfigSource>, message: impl Into<String>, )
Emit an error event.
Trait Implementations§
Source§impl Default for ConfigWatcher
impl Default for ConfigWatcher
Source§fn default() -> ConfigWatcher
fn default() -> ConfigWatcher
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for ConfigWatcher
impl !RefUnwindSafe for ConfigWatcher
impl Send for ConfigWatcher
impl Sync for ConfigWatcher
impl Unpin for ConfigWatcher
impl UnsafeUnpin for ConfigWatcher
impl !UnwindSafe for ConfigWatcher
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<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