Struct BipBufferReader

Source
pub struct BipBufferReader { /* private fields */ }
Expand description

Represents the receive side of the single-producer single-consumer circular buffer.

BipBufferReader is Send so you can move it to the receiver thread.

Implementations§

Source§

impl BipBufferReader

Source

pub fn valid(&mut self) -> &mut [u8]

Returns a mutable reference to a slice that contains the data written by the writer and not yet consumed by the reader. This is the receiving end of the circular buffer.

The caller is free to mutate the data in this slice.

Source

pub fn consume(&mut self, len: usize) -> bool

Consumes the first len bytes in valid. This marks them as read and they won’t be included in the slice returned by the next invocation of valid. This is used to communicate the reader’s progress and free buffer space for future writes.

Source

pub fn try_unwrap<B: DerefMut<Target = [u8]> + 'static>(self) -> Result<B, Self>

Attempts to recover the underlying storage. B must be the type of the storage passed to bip_buffer_from. If the BipBufferWriter side still exists, this will fail and return Err(self). If the BipBufferWriter side was dropped, this will return the underlying storage.

§Panic

Panics if B is not the type of the underlying storage.

Trait Implementations§

Auto Trait Implementations§

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.