pub struct RingBuffer { /* private fields */ }Implementations§
Source§impl RingBuffer
impl RingBuffer
pub fn new(capacity: usize) -> Result<Self, RingBufferError>
Sourcepub unsafe fn from_ptr(
header: *mut RingHeader,
slots: *mut Slot,
capacity: usize,
) -> Self
pub unsafe fn from_ptr( header: *mut RingHeader, slots: *mut Slot, capacity: usize, ) -> Self
Create a ring buffer from raw pointers (for shared memory)
§Safety
The caller must ensure:
headerpoints to a valid RingHeaderslotspoints to an array ofcapacitySlot structures- Memory is properly aligned
pub fn capacity(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn is_full(&self) -> bool
pub fn len(&self) -> u64
pub fn write_slot( &self, priority: Priority, data: &[u8], ) -> Result<SlotId, RingBufferError>
pub fn read_slot(&self) -> Option<(Priority, Vec<u8>)>
pub fn peek_slot(&self) -> Option<(Priority, Vec<u8>)>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RingBuffer
impl RefUnwindSafe for RingBuffer
impl Unpin for RingBuffer
impl UnsafeUnpin for RingBuffer
impl UnwindSafe for RingBuffer
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