pub struct Cbuf { /* private fields */ }Expand description
A thread-safe, lock-protected circular byte buffer.
Implementations§
Source§impl Cbuf
impl Cbuf
Sourcepub fn init() -> impl PinInit<Self, Infallible>
pub fn init() -> impl PinInit<Self, Infallible>
Returns a pin initializer for a new, uninitialized Cbuf.
Sourcepub unsafe fn initialize(&self, len: usize, buf: *mut u8) -> Result<(), Status>
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.
Sourcepub fn write_char(&self, c: u8) -> usize
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.
Sourcepub fn read_char_with_context(&self, block: bool) -> Result<ReadContext, Status>
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.
Trait Implementations§
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 Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
Initializes
slot. Read moreSource§fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where
F: FnOnce(Pin<&mut T>) -> Result<(), E>,
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