Pipe

Struct Pipe 

Source
pub(crate) struct Pipe {
    pub(crate) head: AtomicUsize,
    pub(crate) tail: AtomicUsize,
    pub(crate) reader: AtomicWaker,
    pub(crate) writer: AtomicWaker,
    pub(crate) closed: AtomicBool,
    pub(crate) buffer: *mut u8,
    pub(crate) cap: usize,
}
Expand description

The inner ring buffer.

Head and tail indices are in the range 0..2*cap, even though they really map onto the 0..cap range. The distance between head and tail indices is never more than cap.

The reason why indices are not in the range 0..cap is because we need to distinguish between the pipe being empty and being full. If head and tail were in 0..cap, then head == tail could mean the pipe is either empty or full, but we don’t know which!

Fields§

§head: AtomicUsize

The head index, moved by the reader, in the range 0..2*cap.

§tail: AtomicUsize

The tail index, moved by the writer, in the range 0..2*cap.

§reader: AtomicWaker

A waker representing the blocked reader.

§writer: AtomicWaker

A waker representing the blocked writer.

§closed: AtomicBool

Set to true if the reader or writer was dropped.

§buffer: *mut u8

The byte buffer.

§cap: usize

The buffer capacity.

Implementations§

Source§

impl Pipe

Source

pub(crate) fn len(&self) -> usize

Get the length of the data in the pipe.

Trait Implementations§

Source§

impl Drop for Pipe

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Pipe

Source§

impl Sync for Pipe

Auto Trait Implementations§

§

impl !Freeze for Pipe

§

impl !RefUnwindSafe for Pipe

§

impl Unpin for Pipe

§

impl UnwindSafe for Pipe

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.