async_ringbuf::rb

Struct AsyncRb

Source
pub struct AsyncRb<S: Storage> { /* private fields */ }

Implementations§

Source§

impl<T> AsyncRb<Heap<T>>

Source

pub fn new(cap: usize) -> Self

Source§

impl<S: Storage> AsyncRb<S>

Source

pub fn from(base: SharedRb<S>) -> Self

Trait Implementations§

Source§

impl<S: Storage> AsMut<AsyncRb<S>> for AsyncRb<S>

Source§

fn as_mut(&mut self) -> &mut Self

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<S: Storage> AsRef<AsyncRb<S>> for AsyncRb<S>

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<S: Storage> Consumer for AsyncRb<S>

Source§

unsafe fn set_read_index(&self, value: usize)

Set read index. Read more
§

unsafe fn advance_read_index(&self, count: usize)

Moves read pointer by count places forward. Read more
§

fn occupied_slices( &self, ) -> (&[MaybeUninit<Self::Item>], &[MaybeUninit<Self::Item>])

Provides a direct access to the ring buffer occupied memory. The difference from Self::as_slices is that this method provides slices of MaybeUninit, so items may be moved out of slices. Read more
§

unsafe fn occupied_slices_mut( &mut self, ) -> (&mut [MaybeUninit<Self::Item>], &mut [MaybeUninit<Self::Item>])

Provides a direct mutable access to the ring buffer occupied memory. Read more
§

fn as_slices(&self) -> (&[Self::Item], &[Self::Item])

Returns a pair of slices which contain, in order, the contents of the ring buffer.
§

fn as_mut_slices(&mut self) -> (&mut [Self::Item], &mut [Self::Item])

Returns a pair of mutable slices which contain, in order, the contents of the ring buffer.
§

fn first(&self) -> Option<&Self::Item>

Returns a reference to the eldest item in the ring buffer, if exists.
§

fn first_mut(&mut self) -> Option<&mut Self::Item>

Returns a mutable reference to the eldest item in the ring buffer, if exists.
§

fn last(&self) -> Option<&Self::Item>

Returns a reference to the most recent item in the ring buffer, if exists. Read more
§

fn last_mut(&mut self) -> Option<&mut Self::Item>

Returns a mutable reference to the most recent item in the ring buffer, if exists. Read more
§

fn try_pop(&mut self) -> Option<Self::Item>

Removes the eldest item from the ring buffer and returns it. Read more
§

fn try_peek(&self) -> Option<&Self::Item>

Returns the reference to the eldest item without removing it from the buffer. Read more
§

fn peek_slice_uninit(&self, elems: &mut [MaybeUninit<Self::Item>]) -> usize

Copies items from the ring buffer to an uninit slice without removing them from the ring buffer. Read more
§

fn peek_slice(&self, elems: &mut [Self::Item]) -> usize
where Self::Item: Copy,

Copies items from the ring buffer to a slice without removing them from the ring buffer. Read more
§

fn pop_slice_uninit(&mut self, elems: &mut [MaybeUninit<Self::Item>]) -> usize

Removes items from the ring buffer and writes them into an uninit slice. Read more
§

fn pop_slice(&mut self, elems: &mut [Self::Item]) -> usize
where Self::Item: Copy,

Removes items from the ring buffer and writes them into a slice. Read more
§

fn pop_iter(&mut self) -> PopIter<'_, Self>

Returns an iterator that removes items one by one from the ring buffer.
§

fn iter(&self) -> Chain<Iter<'_, Self::Item>, Iter<'_, Self::Item>>

Returns a front-to-back iterator containing references to items in the ring buffer. Read more
§

fn iter_mut( &mut self, ) -> Chain<IterMut<'_, Self::Item>, IterMut<'_, Self::Item>>

Returns a front-to-back iterator that returns mutable references to items in the ring buffer. Read more
§

fn skip(&mut self, count: usize) -> usize

Removes at most count and at least min(count, Self::len()) items from the buffer and safely drops them. Read more
§

fn clear(&mut self) -> usize

Removes all items from the buffer and safely drops them. Read more
§

fn write_into<S>( &mut self, writer: &mut S, count: Option<usize>, ) -> Option<Result<usize, Error>>
where S: Write, Self: Consumer<Item = u8>,

Removes at most first count bytes from the ring buffer and writes them into a Write instance. If count is None then as much as possible bytes will be written. Read more
Source§

impl<T, const N: usize> Default for AsyncRb<Array<T, N>>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<S: Storage> Observer for AsyncRb<S>

Source§

type Item = <S as Storage>::Item

Source§

fn capacity(&self) -> NonZeroUsize

Capacity of the ring buffer. Read more
Source§

fn read_index(&self) -> usize

Index of the last item in the ring buffer. Read more
Source§

fn write_index(&self) -> usize

Index of the next empty slot in the ring buffer. Read more
Source§

unsafe fn unsafe_slices( &self, start: usize, end: usize, ) -> (&[MaybeUninit<S::Item>], &[MaybeUninit<S::Item>])

Get slice between start and end indices. Read more
Source§

unsafe fn unsafe_slices_mut( &self, start: usize, end: usize, ) -> (&mut [MaybeUninit<S::Item>], &mut [MaybeUninit<S::Item>])

Get mutable slice between start and end indices. Read more
Source§

fn read_is_held(&self) -> bool

Whether read end is held by consumer.
Source§

fn write_is_held(&self) -> bool

Whether write end is held by producer.
§

fn occupied_len(&self) -> usize

The number of items stored in the buffer. Read more
§

fn vacant_len(&self) -> usize

The number of remaining free places in the buffer. Read more
§

fn is_empty(&self) -> bool

Checks if the ring buffer is empty. Read more
§

fn is_full(&self) -> bool

Checks if the ring buffer is full. Read more
Source§

impl<S: Storage> Producer for AsyncRb<S>

Source§

unsafe fn set_write_index(&self, value: usize)

Set read index. Read more
§

unsafe fn advance_write_index(&self, count: usize)

Moves write pointer by count places forward. Read more
§

fn vacant_slices( &self, ) -> (&[MaybeUninit<Self::Item>], &[MaybeUninit<Self::Item>])

Provides a direct access to the ring buffer vacant memory. Read more
§

fn vacant_slices_mut( &mut self, ) -> (&mut [MaybeUninit<Self::Item>], &mut [MaybeUninit<Self::Item>])

Mutable version of Self::vacant_slices. Read more
§

fn try_push(&mut self, elem: Self::Item) -> Result<(), Self::Item>

Appends an item to the ring buffer. Read more
§

fn push_iter<I>(&mut self, iter: I) -> usize
where I: Iterator<Item = Self::Item>,

Appends items from an iterator to the ring buffer. Elements that haven’t been added to the ring buffer remain in the iterator. Read more
§

fn push_slice(&mut self, elems: &[Self::Item]) -> usize
where Self::Item: Copy,

Appends items from slice to the ring buffer. Read more
§

fn read_from<S>( &mut self, reader: &mut S, count: Option<usize>, ) -> Option<Result<usize, Error>>
where S: Read, Self: Producer<Item = u8>,

Reads at most count bytes from Read instance and appends them to the ring buffer. If count is None then as much as possible bytes will be read. Read more
Source§

impl<S: Storage> RingBuffer for AsyncRb<S>

Source§

unsafe fn hold_read(&self, flag: bool) -> bool

Tell whether read end of the ring buffer is held by consumer or not. Read more
Source§

unsafe fn hold_write(&self, flag: bool) -> bool

Tell whether write end of the ring buffer is held by producer or not. Read more
§

fn push_overwrite(&mut self, elem: Self::Item) -> Option<Self::Item>

Pushes an item to the ring buffer overwriting the latest item if the buffer is full. Read more
§

fn push_iter_overwrite<I>(&mut self, iter: I)
where I: Iterator<Item = Self::Item>,

Appends items from an iterator to the ring buffer. Read more
§

fn push_slice_overwrite(&mut self, elems: &[Self::Item])
where Self::Item: Copy,

Appends items from slice to the ring buffer overwriting existing items in the ring buffer. Read more
Source§

impl<S: Storage> Split for AsyncRb<S>

Source§

type Prod = AsyncWrap<Arc<AsyncRb<S>>, true, false>

Producer type.
Source§

type Cons = AsyncWrap<Arc<AsyncRb<S>>, false, true>

Consumer type.
Source§

fn split(self) -> (Self::Prod, Self::Cons)

Perform splitting.
Source§

impl<S: Storage> SplitRef for AsyncRb<S>

Source§

type RefProd<'a> = AsyncWrap<&'a AsyncRb<S>, true, false> where Self: 'a

Ref producer type.
Source§

type RefCons<'a> = AsyncWrap<&'a AsyncRb<S>, false, true> where Self: 'a

Ref consumer type.
Source§

fn split_ref(&mut self) -> (Self::RefProd<'_>, Self::RefCons<'_>)

Perform splitting by reference.
Source§

impl<S: Storage> Unpin for AsyncRb<S>

Auto Trait Implementations§

§

impl<S> !Freeze for AsyncRb<S>

§

impl<S> !RefUnwindSafe for AsyncRb<S>

§

impl<S> Send for AsyncRb<S>
where S: Send,

§

impl<S> Sync for AsyncRb<S>
where S: Sync,

§

impl<S> UnwindSafe for AsyncRb<S>
where S: UnwindSafe,

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