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. The writer
will write from the beginning of the ring buffer. If you need to continue writing to the
previous buffer use RingBuffer::join_writer instead.
Sourcepub fn join_writer(self) -> Writer
pub fn join_writer(self) -> Writer
Will consume self and return instance of writer backed by this ring buffer. The writer
will not reset current producer_position and will continue writing from that point.
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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more