Trait ringbuf::ring_buffer::RbWrite
source · pub trait RbWrite<T>: RbBase<T> {
// Required method
unsafe fn set_tail(&self, value: usize);
// Provided methods
unsafe fn advance_tail(&self, count: usize) { ... }
fn vacant_ranges(&self) -> (Range<usize>, Range<usize>) { ... }
unsafe fn vacant_slices(
&self
) -> (&mut [MaybeUninit<T>], &mut [MaybeUninit<T>]) { ... }
}
Expand description
Required Methods§
Provided Methods§
sourceunsafe fn advance_tail(&self, count: usize)
unsafe fn advance_tail(&self, count: usize)
Move tail position by count
items forward.
Safety
First count
items in vacant area must be de-initialized (dropped) before this call.
In debug mode panics if count
is greater than number of vacant places in the ring buffer.
sourcefn vacant_ranges(&self) -> (Range<usize>, Range<usize>)
fn vacant_ranges(&self) -> (Range<usize>, Range<usize>)
Returns a pair of ranges of Self::vacant_slices
location in underlying container.
sourceunsafe fn vacant_slices(&self) -> (&mut [MaybeUninit<T>], &mut [MaybeUninit<T>])
unsafe fn vacant_slices(&self) -> (&mut [MaybeUninit<T>], &mut [MaybeUninit<T>])
Provides a direct access to the ring buffer vacant memory. Returns a pair of slices of uninitialized memory, the second one may be empty.
Safety
Vacant memory is uninitialized. Initialized items must be put starting from the beginning of first slice. When first slice is fully filled then items must be put to the beginning of the second slice.
This method must be followed by Self::advance_tail
call with the number of items being put previously as argument.
No other mutating calls allowed before that.