pub struct Bus { /* private fields */ }Implementations§
Source§impl Bus
impl Bus
pub fn new() -> Self
pub fn get_default() -> Self
pub fn send<T: BusType>(&self, msg: T)
pub fn send_event<T: BusType>(&self, event: BusEvent<T>)
pub fn send_serde_event(&self, type_id: &TypeId, event: BusEvent<SerdePayload>)
Sourcepub fn update_latest<T: Default + BusType>(&self, f: impl FnOnce(T) -> T)
pub fn update_latest<T: Default + BusType>(&self, f: impl FnOnce(T) -> T)
Provides a convenient way to get the latest value, update it, and re-push it to the bus. Value will be created from Default::default if it has never been seen in the bus before.
Only provides an atomic update if this is the only way this type is pushed to the bus. Then it is atomic even if called from multiple threads (the lock on latest is not released until the new value is pushed to the bus).
pub fn subscribe<T: BusType>( &self, prefix_latest: bool, ) -> Receiver<BusEvent<T>>
pub fn subscribe_serde( &self, type_id: &TypeId, ) -> Receiver<BusEvent<SerdePayload>>
pub fn get_latest<T: BusType>(&self) -> Option<BusEvent<T>>
pub fn trace_events<T: BusType + Debug>(&self) -> JoinHandle<()>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Bus
impl !RefUnwindSafe for Bus
impl Send for Bus
impl Sync for Bus
impl Unpin for Bus
impl !UnwindSafe for Bus
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