pub struct EventBuf<T: Copy, const N: usize> { /* private fields */ }Expand description
Bounded SPSC event buffer with backpressure.
When the buffer is full, Producer::push returns Err(val) instead
of overwriting, giving the producer a chance to retry, drop, or log.
The consumer drains items with Consumer::pop or Consumer::drain.
§Panics
EventBuf::new()panics ifN == 0.producer()/consumer()panic if called while another handle of the same kind is already active.
Implementations§
Source§impl<T: Copy, const N: usize> EventBuf<T, N>
impl<T: Copy, const N: usize> EventBuf<T, N>
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Approximate number of items currently buffered.
This is a snapshot — by the time the caller acts on it the value may already be stale.
Trait Implementations§
impl<T: Copy + Send, const N: usize> Sync for EventBuf<T, N>
Auto Trait Implementations§
impl<T, const N: usize> !Freeze for EventBuf<T, N>
impl<T, const N: usize> !RefUnwindSafe for EventBuf<T, N>
impl<T, const N: usize> Send for EventBuf<T, N>where
T: Send,
impl<T, const N: usize> Unpin for EventBuf<T, N>where
T: Unpin,
impl<T, const N: usize> UnwindSafe for EventBuf<T, N>where
T: UnwindSafe,
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