pub struct ReadView<'a, T, PW: OptionalWaiter, CW: OptionalWaiter> {
pub slices: (&'a mut [T], &'a mut [T]),
/* private fields */
}Expand description
Ring buffer available contents, as two slices.
The two slices are similar to how VecDeque::to_slices work - when concatenated, they
contain the available contents of the buffer at the time of calling.
After the contents have been examined, you may call consume or consume_all to remove the items
from the buffer and free up their slots for the producer.
Fields§
§slices: (&'a mut [T], &'a mut [T])Implementations§
Source§impl<'a, T, PW: OptionalWaiter, CW: OptionalWaiter> ReadView<'a, T, PW, CW>
impl<'a, T, PW: OptionalWaiter, CW: OptionalWaiter> ReadView<'a, T, PW, CW>
Sourcepub fn consume(self, amnt: usize)
pub fn consume(self, amnt: usize)
Consumes the first amnt items from the buffer, dropping them and
freeing the slots for the producer to fill.
amnt is clamped to the number of items in this view.
Sourcepub fn consume_all(self)
pub fn consume_all(self)
Consumes all items in this view from the buffer.
Sourcepub fn iter(&mut self) -> Chain<IterMut<'_, T>, IterMut<'_, T>>
pub fn iter(&mut self) -> Chain<IterMut<'_, T>, IterMut<'_, T>>
Iterates through each available element, in order.
Equivalent to chaining the two slice’s iterators.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if the view is empty.
Equivalent to testing if the first slices is empty. If the first slice is empty, the second one will be as well.