pub struct EventBuffer { /* private fields */ }Expand description
Thread-safe event buffer for deferring event emissions during transactions.
Repositories push events into this buffer instead of sending them directly to the EventHub. On commit(), the UoW drains the buffer and sends all events. On rollback(), the buffer is discarded. This prevents the UI from seeing phantom state from failed transactions.
This is the Rust equivalent of SignalBuffer in the C++/Qt target.
Implementations§
Source§impl EventBuffer
impl EventBuffer
pub fn new() -> Self
Sourcepub fn begin_buffering(&mut self)
pub fn begin_buffering(&mut self)
Start buffering. Clears any stale events from a previous cycle.
Sourcepub fn push(&mut self, event: Event)
pub fn push(&mut self, event: Event)
Queue an event for deferred delivery.
If buffering is not active, the event is silently dropped. (Callers should only push during an active transaction.)
Sourcepub fn flush(&mut self) -> Vec<Event>
pub fn flush(&mut self) -> Vec<Event>
Drain all pending events and stop buffering. The caller is responsible for sending them to the EventHub.
pub fn is_buffering(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EventBuffer
impl RefUnwindSafe for EventBuffer
impl Send for EventBuffer
impl Sync for EventBuffer
impl Unpin for EventBuffer
impl UnsafeUnpin for EventBuffer
impl UnwindSafe for EventBuffer
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