Skip to main content

Subscription

Struct Subscription 

Source
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

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Subscription

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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.