pub struct ObserverBus { /* private fields */ }Expand description
Holds strong Arc references so FFI-registered observers stay alive for the
bus’s lifetime. The FFI boundary passes a Box<dyn Observer> once and never
holds another strong reference on the caller side, so the bus must own it.
Rust-side callers that want lifecycle control can drop the entire bus or
call clear() to release all observers at once.
Implementations§
Source§impl ObserverBus
impl ObserverBus
pub fn with_logger(self, logger: Arc<Logger>) -> Self
pub fn register(&self, obs: Arc<dyn Observer>)
pub fn emit(&self, event: ChangeEvent)
Sourcepub fn clear(&self)
pub fn clear(&self)
Releases all registered observers. Primarily intended for tests and shutdown paths.
pub fn live_count(&self) -> usize
Trait Implementations§
Source§impl Default for ObserverBus
impl Default for ObserverBus
Source§fn default() -> ObserverBus
fn default() -> ObserverBus
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for ObserverBus
impl RefUnwindSafe for ObserverBus
impl Send for ObserverBus
impl Sync for ObserverBus
impl Unpin for ObserverBus
impl UnwindSafe for ObserverBus
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