pub struct Consumer<'a, T: Copy, const N: usize> { /* private fields */ }Expand description
Consumer handle for reading from the ring.
This handle is !Sync to prevent concurrent consumers.
Implementations§
Source§impl<'a, T: Copy, const N: usize> Consumer<'a, T, N>
impl<'a, T: Copy, const N: usize> Consumer<'a, T, N>
Sourcepub fn dropped(&self) -> usize
pub fn dropped(&self) -> usize
How many items have been dropped since consumer creation (or since reset).
Sourcepub fn reset_dropped(&mut self)
pub fn reset_dropped(&mut self)
Reset the internal drop counter.
Sourcepub fn poll_one(&mut self, hook: impl FnOnce(u32, &T)) -> bool
pub fn poll_one(&mut self, hook: impl FnOnce(u32, &T)) -> bool
Drain at most one item (in-order). Returns true if an item was delivered to the hook.
Sourcepub fn poll_up_to(&mut self, max: usize, hook: impl FnMut(u32, &T)) -> PollStats
pub fn poll_up_to(&mut self, max: usize, hook: impl FnMut(u32, &T)) -> PollStats
Drain up to max items (in-order).
Hook sees &T but it is a reference to a local copy inside poll.
If max == 0, this returns immediately with read = 0, dropped = 0, and
newest set to the latest published sequence.
Sourcepub fn latest(&self, hook: impl FnOnce(u32, &T)) -> bool
pub fn latest(&self, hook: impl FnOnce(u32, &T)) -> bool
“Give me the newest thing right now” (not in-order). Returns true if it delivered something.
This does not advance the consumer cursor.
Sourcepub fn skip_to_latest(&mut self)
pub fn skip_to_latest(&mut self)
Fast-forward consumer so the next poll_one() yields the newest item
(i.e. skip backlog).
This does not modify the dropped counter.