pub struct Subscription { /* private fields */ }Expand description
RAII handle for a registered change-notification handler.
Returned by HotReloadConfig::on_change /
HotReloadHandle::on_change. Drop the Subscription to
unregister the handler. The watcher itself outlives any individual
subscription — multiple subscriptions can come and go without
touching the underlying HotReloadConfig.
§Example
use config_lib::hot_reload::{HotReloadConfig, ConfigChangeEvent};
let hot = HotReloadConfig::from_file("app.conf")?;
let _subscription = hot.on_change(|event: &ConfigChangeEvent| {
println!("config changed: {event:?}");
});
// Drop `_subscription` (e.g. at end of scope) to unregister.Implementations§
Source§impl Subscription
impl Subscription
Sourcepub fn forget(self)
pub fn forget(self)
Detach the subscription from its drop-based unregistration
hook. The handler stays registered for the lifetime of the
underlying watcher (until the HotReloadConfig or
HotReloadHandle that produced it is dropped).
Useful for global / process-lifetime handlers where the
caller has no convenient owning scope to hold the
Subscription.
Trait Implementations§
Source§impl Debug for Subscription
impl Debug for Subscription
Source§impl Drop for Subscription
impl Drop for Subscription
Auto Trait Implementations§
impl Freeze for Subscription
impl !RefUnwindSafe for Subscription
impl Send for Subscription
impl Sync for Subscription
impl Unpin for Subscription
impl UnsafeUnpin for Subscription
impl !UnwindSafe for Subscription
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