Struct anchor::FifoBuffer
source · pub struct FifoBuffer<const BUF_SIZE: usize> { /* private fields */ }
Expand description
FIFO buffer
This implements a simple FIFO buffer which can be useful when managing data to/from Anchor protocol handling. Using this is completely optional, it is provided as a convenience.
Implementations§
source§impl<const BUF_SIZE: usize> FifoBuffer<BUF_SIZE>
impl<const BUF_SIZE: usize> FifoBuffer<BUF_SIZE>
sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new buffer
This is declared const, allowing it to be used even in static const
contexts.
sourcepub fn receive_buffer(&mut self) -> &mut [u8] ⓘ
pub fn receive_buffer(&mut self) -> &mut [u8] ⓘ
Return mutable slice to the non-filled part of the buffer
sourcepub fn extend(&mut self, buf: &[u8])
pub fn extend(&mut self, buf: &[u8])
Append buf
to the non-filled part of the buffer
Any excess will be discarded.
Auto Trait Implementations§
impl<const BUF_SIZE: usize> Freeze for FifoBuffer<BUF_SIZE>
impl<const BUF_SIZE: usize> RefUnwindSafe for FifoBuffer<BUF_SIZE>
impl<const BUF_SIZE: usize> Send for FifoBuffer<BUF_SIZE>
impl<const BUF_SIZE: usize> Sync for FifoBuffer<BUF_SIZE>
impl<const BUF_SIZE: usize> Unpin for FifoBuffer<BUF_SIZE>
impl<const BUF_SIZE: usize> UnwindSafe for FifoBuffer<BUF_SIZE>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more