ReadView

Struct ReadView 

Source
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>

Source

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.

Source

pub fn consume_all(self)

Consumes all items in this view from the buffer.

Source

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.

Source

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.

Source

pub fn len(&self) -> usize

Gets how many items are in the view.

This is the sum of the lengths of the two slices.

Source

pub fn get(&self, i: usize) -> Option<&T>

Gets an item from the view, at the i’th place, or None if out of bounds.

Mimics slice::get.

Trait Implementations§

Source§

impl<'a, T, PW: OptionalWaiter, CW: OptionalWaiter> Deref for ReadView<'a, T, PW, CW>

Source§

type Target = (&'a mut [T], &'a mut [T])

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, T, PW: OptionalWaiter, CW: OptionalWaiter> DerefMut for ReadView<'a, T, PW, CW>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'a, T, PW: OptionalWaiter, CW: OptionalWaiter> Index<usize> for ReadView<'a, T, PW, CW>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, i: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<'a, T, PW, CW> Freeze for ReadView<'a, T, PW, CW>

§

impl<'a, T, PW, CW> RefUnwindSafe for ReadView<'a, T, PW, CW>

§

impl<'a, T, PW, CW> Send for ReadView<'a, T, PW, CW>
where T: Send,

§

impl<'a, T, PW, CW> Sync for ReadView<'a, T, PW, CW>
where T: Send + Sync,

§

impl<'a, T, PW, CW> Unpin for ReadView<'a, T, PW, CW>

§

impl<'a, T, PW, CW> !UnwindSafe for ReadView<'a, T, PW, CW>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.