pub struct WatcherManager<T> { /* private fields */ }Expand description
Manages a collection of watchers for a specific computation type.
Provides functionality to register, notify, and cancel watchers.
Implementations§
Source§impl<T: 'static> WatcherManager<T>
impl<T: 'static> WatcherManager<T>
Sourcepub fn register(&self, watcher: impl Fn(Context<T>) + 'static) -> NonZeroUsize
pub fn register(&self, watcher: impl Fn(Context<T>) + 'static) -> NonZeroUsize
Registers a new watcher and returns its unique identifier.
Sourcepub fn register_as_guard(
&self,
watcher: impl Fn(Context<T>) + 'static,
) -> WatcherManagerGuard<T>
pub fn register_as_guard( &self, watcher: impl Fn(Context<T>) + 'static, ) -> WatcherManagerGuard<T>
Registers a watcher and returns a guard that will unregister it when dropped.
Sourcepub fn notify(&self, ctx: &Context<T>)where
T: Clone,
pub fn notify(&self, ctx: &Context<T>)where
T: Clone,
Notifies all registered watchers with a preconstructed context.
Sourcepub fn cancel(&self, id: NonZeroUsize)
pub fn cancel(&self, id: NonZeroUsize)
Cancels a previously registered watcher by its identifier.
Trait Implementations§
Source§impl<T> Clone for WatcherManager<T>
impl<T> Clone for WatcherManager<T>
Source§impl<T: Debug> Debug for WatcherManager<T>
impl<T: Debug> Debug for WatcherManager<T>
Auto Trait Implementations§
impl<T> Freeze for WatcherManager<T>
impl<T> !RefUnwindSafe for WatcherManager<T>
impl<T> !Send for WatcherManager<T>
impl<T> !Sync for WatcherManager<T>
impl<T> Unpin for WatcherManager<T>
impl<T> !UnwindSafe for WatcherManager<T>
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