[−][src]Struct ringbuf::Producer
Producer part of ring buffer.
Methods
impl<T: Sized> Producer<T>
[src]
pub fn capacity(&self) -> usize
[src]
Returns capacity of the ring buffer.
pub fn is_empty(&self) -> bool
[src]
Checks if the ring buffer is empty.
pub fn is_full(&self) -> bool
[src]
Checks if the ring buffer is full.
pub fn len(&self) -> usize
[src]
The length of the data in the buffer.
pub fn remaining(&self) -> usize
[src]
The remaining space in the buffer.
pub fn push(&mut self, elem: T) -> Result<(), PushError<T>>
[src]
Appends an element to the ring buffer. On failure returns an error containing the element that hasn't beed appended.
impl<T: Sized + Copy> Producer<T>
[src]
pub fn push_slice(&mut self, elems: &[T]) -> Result<usize, PushSliceError>
[src]
Appends elements from slice to the ring buffer.
Elements should be Copy
.
On success returns count of elements been appended to the ring buffer.
pub fn move_slice(
&mut self,
other: &mut Consumer<T>,
count: Option<usize>
) -> Result<usize, MoveSliceError>
[src]
&mut self,
other: &mut Consumer<T>,
count: Option<usize>
) -> Result<usize, MoveSliceError>
Removes at most count
elements from the Consumer
of the ring buffer
and appends them to the Producer
of the another one.
If count
is None
then as much as possible elements will be moved.
Elements should be Copy
.
On success returns count of elements been moved.
impl Producer<u8>
[src]
pub fn read_from(
&mut self,
reader: &mut dyn Read,
count: Option<usize>
) -> Result<usize, ReadFromError>
[src]
&mut self,
reader: &mut dyn Read,
count: Option<usize>
) -> Result<usize, ReadFromError>
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.
impl<T: Sized> Producer<T>
[src]
pub unsafe fn push_access<R, E, F>(
&mut self,
f: F
) -> Result<Result<(usize, R), E>, PushAccessError> where
R: Sized,
E: Sized,
F: FnOnce(&mut [T], &mut [T]) -> Result<(usize, R), E>,
[src]
&mut self,
f: F
) -> Result<Result<(usize, R), E>, PushAccessError> where
R: Sized,
E: Sized,
F: FnOnce(&mut [T], &mut [T]) -> Result<(usize, R), E>,
Allows to write into ring buffer memory directry.
This function is unsafe beacuse it gives access to possibly uninitialized memory and transfers to the user the responsibility of manually calling destructors
Takes a function f
as argument.
f
takes two slices of ring buffer content (the second one may be empty). First slice contains older elements.
f
should return:
+ On success: pair of number of elements been written, and some arbitrary data.
+ On failure: some another arbitrary data.
On success returns data returned from f
.
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 write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[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> 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>
impl<T> !RefUnwindSafe for Producer<T>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,