[−][src]Struct ringbuf::Producer
Producer part of ring buffer.
Implementations
impl<T: Sized> Producer<T>
[src]
pub fn capacity(&self) -> usize
[src]
Returns capacity of the ring buffer.
The capacity of the buffer is constant.
pub fn is_empty(&self) -> bool
[src]
Checks if the ring buffer is empty.
The result is relevant until you push items to the producer.
pub fn is_full(&self) -> bool
[src]
Checks if the ring buffer is full.
The result may become irrelevant at any time because of concurring activity of the consumer.
pub fn len(&self) -> usize
[src]
The length of the data stored in the buffer.
Actual length may be equal to or less than the returned value.
pub fn remaining(&self) -> usize
[src]
The remaining space in the buffer.
Actual remaining space may be equal to or greater than the returning value.
pub unsafe fn push_access<F>(&mut self, f: F) -> usize where
F: FnOnce(&mut [MaybeUninit<T>], &mut [MaybeUninit<T>]) -> usize,
[src]
F: FnOnce(&mut [MaybeUninit<T>], &mut [MaybeUninit<T>]) -> usize,
Allows to write into ring buffer memory directry.
This function is unsafe because it gives access to possibly uninitialized memory
The method takes a function f
as argument.
f
takes two slices of ring buffer content (the second one or both of them may be empty).
First slice contains older elements.
f
should return number of elements been written.
There is no checks for returned number - it remains on the developer's conscience.
The method always calls f
even if ring buffer is full.
The method returns number returned from f
.
pub unsafe fn push_copy(&mut self, elems: &[MaybeUninit<T>]) -> usize
[src]
Copies data from the slice to the ring buffer in byte-to-byte manner.
The elems
slice should contain initialized data before the method call.
After the call the copied part of data in elems
should be interpreted as un-initialized.
Returns the number of items been copied.
pub fn push(&mut self, elem: T) -> Result<(), T>
[src]
Appends an element to the ring buffer. On failure returns an error containing the element that hasn't beed appended.
pub fn push_each<F: FnMut() -> Option<T>>(&mut self, f: F) -> usize
[src]
Repeatedly calls the closure f
and pushes elements returned from it to the ring buffer.
The closure is called until it returns None
or the ring buffer is full.
The method returns number of elements been put into the buffer.
pub fn push_iter<I: Iterator<Item = T>>(&mut self, elems: &mut I) -> usize
[src]
Appends elements from an iterator to the ring buffer. Elements that haven't been added to the ring buffer remain in the iterator.
Returns count of elements been appended to the ring buffer.
pub fn move_from(
&mut self,
other: &mut Consumer<T>,
count: Option<usize>
) -> usize
[src]
&mut self,
other: &mut Consumer<T>,
count: Option<usize>
) -> usize
Removes at most count
elements from the consumer and appends them to the producer.
If count
is None
then as much as possible elements will be moved.
The producer and consumer parts may be of different buffers as well as of the same one.
On success returns number of elements been moved.
impl<T: Sized + Copy> Producer<T>
[src]
pub fn push_slice(&mut self, elems: &[T]) -> usize
[src]
Appends elements from slice to the ring buffer.
Elements should be Copy
.
Returns count of elements been appended to the ring buffer.
impl Producer<u8>
[src]
pub fn read_from(
&mut self,
reader: &mut dyn Read,
count: Option<usize>
) -> Result<usize>
[src]
&mut self,
reader: &mut dyn Read,
count: Option<usize>
) -> Result<usize>
Reads at most count
bytes
from Read
instance
and appends them to the ring buffer.
If count
is None
then as much as possible bytes will be read.
Returns Ok(n)
if read
is succeded. n
is number of bytes been read.
n == 0
means that either read
returned zero or ring buffer is full.
If read
is failed then error is returned.
Trait Implementations
impl Write for Producer<u8>
[src]
fn write(&mut self, buffer: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>
1.36.0[src]
fn is_write_vectored(&self) -> bool
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_all_vectored(&mut self, bufs: &mut [IoSlice]) -> Result<(), Error>
[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for Producer<T>
impl<T> Send for Producer<T> where
T: Send,
T: Send,
impl<T> Sync for Producer<T> where
T: Send,
T: Send,
impl<T> Unpin for Producer<T>
impl<T> !UnwindSafe for Producer<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,