pub struct RingBuffer { /* private fields */ }Expand description
Single producer, many consumer (SPMC) ring buffer backed by shared memory.
Implementations§
Source§impl RingBuffer
impl RingBuffer
Sourcepub fn new(bytes: &[u8]) -> Self
pub fn new(bytes: &[u8]) -> Self
Create new RingBuffer by wrapping provided bytes. It is necessary to call into_writer()
or into_reader() following the buffer construction to start using it.
Sourcepub fn into_writer(self) -> Writer
pub fn into_writer(self) -> Writer
Will consume self and return instance of writer backed by this ring buffer.
Sourcepub fn into_writer_with_metadata<F: FnOnce(&mut [u8])>(
self,
metadata: F,
) -> Writer
pub fn into_writer_with_metadata<F: FnOnce(&mut [u8])>( self, metadata: F, ) -> Writer
Will consume self and return instance of writer backed by this ring buffer. This
method also accepts closure to populate metadata buffer.
Sourcepub fn into_reader(self) -> Reader
pub fn into_reader(self) -> Reader
Will consume self and return instance of reader backed by this ring buffer. The reader
position will be set to producer most up-to-date position.
Trait Implementations§
Source§impl Clone for RingBuffer
impl Clone for RingBuffer
Source§fn clone(&self) -> RingBuffer
fn clone(&self) -> RingBuffer
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RingBuffer
impl Debug for RingBuffer
Source§impl From<RingBuffer> for Writer
impl From<RingBuffer> for Writer
Source§fn from(ring: RingBuffer) -> Self
fn from(ring: RingBuffer) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for RingBuffer
impl RefUnwindSafe for RingBuffer
impl !Send for RingBuffer
impl !Sync for RingBuffer
impl Unpin 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