Skip to main content

Cbuf

Struct Cbuf 

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

A thread-safe, lock-protected circular byte buffer.

Implementations§

Source§

impl Cbuf

Source

pub fn project<'__pin>(self: Pin<&'__pin mut Self>) -> CbufProjection<'__pin>

Pin-projects all fields of Self.

These fields are structurally pinned:

  • event
  • lock

These fields are not structurally pinned:

  • head
  • tail
  • len_pow2
  • buf
Source§

impl Cbuf

Source

pub fn lock_lock(&self) -> impl PinInit<CbufLockGuard<'_>, Infallible>

Source§

impl Cbuf

Source

pub fn init() -> impl PinInit<Self, Infallible>

Returns a pin initializer for a new, uninitialized Cbuf.

Source

pub unsafe fn initialize(&self, len: usize, buf: *mut u8) -> Result<(), Status>

Initializes the circular buffer with the specified size and backing memory region.

§Safety

The caller must ensure that buf points to a valid memory region of at least len bytes, and that this memory region remains valid for the lifetime of Cbuf.

Source

pub fn full(&self) -> bool

Returns true if the buffer is currently full.

Source

pub fn write_char(&self, c: u8) -> usize

Writes a single character to the buffer if space is available.

Returns 1 if the write succeeded, or 0 if the buffer was full.

Source

pub fn read_char_with_context(&self, block: bool) -> Result<ReadContext, Status>

Reads a single character from the buffer, returning it along with the transition context.

If block is true, this function blocks until a character is available to read. If block is false, it returns Err(Status::SHOULD_WAIT) if no character is available.

Source

pub fn read_char(&self, block: bool) -> Result<u8, Status>

Reads a single character from the buffer.

If block is true, this function blocks until a character is available to read. If block is false, it returns Err(Status::SHOULD_WAIT) if no character is available.

Trait Implementations§

Source§

impl HasPinData for Cbuf

Source§

type PinData = __ThePinData

Source§

unsafe fn __pin_data() -> Self::PinData

Source§

impl Send for Cbuf

Source§

impl Sync for Cbuf

Auto Trait Implementations§

§

impl !Freeze for Cbuf

§

impl !RefUnwindSafe for Cbuf

§

impl UnsafeUnpin for Cbuf

§

impl UnwindSafe for Cbuf

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Init<T> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
§

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

§

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> PinInit<T> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.