pub struct EventPublisher<T> { /* private fields */ }Expand description
The write side. Single producer: &mut self enforces it without atomics.
Implementations§
Source§impl<T> EventPublisher<T>
impl<T> EventPublisher<T>
Sourcepub fn publish(&mut self, f: impl FnOnce(&mut T))
pub fn publish(&mut self, f: impl FnOnce(&mut T))
Fill the next slot, blocking until a subscriber frees one.
The closure receives the slot’s existing value to mutate. Nothing is
allocated or copied, so a payload that owns a String or Vec reuses
the capacity it had from the previous time round the ring.
If the closure panics the value is left as the closure altered it —
still a valid T — and the message is not published.
Sourcepub fn try_publish(&mut self, f: impl FnOnce(&mut T)) -> bool
pub fn try_publish(&mut self, f: impl FnOnce(&mut T)) -> bool
Fill the next slot, or return false if that would overtake a subscriber.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for EventPublisher<T>
impl<T> !UnwindSafe for EventPublisher<T>
impl<T> Freeze for EventPublisher<T>
impl<T> Sync for EventPublisher<T>
impl<T> Unpin for EventPublisher<T>
impl<T> UnsafeUnpin for EventPublisher<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