Struct embassy_hal_internal::atomic_ring_buffer::Writer
source · pub struct Writer<'a>(/* private fields */);
Expand description
A type which can only write to a ring buffer.
Implementations§
source§impl<'a> Writer<'a>
impl<'a> Writer<'a>
sourcepub fn push(&mut self, f: impl FnOnce(&mut [u8]) -> usize) -> usize
pub fn push(&mut self, f: impl FnOnce(&mut [u8]) -> usize) -> usize
Push data into the buffer in-place.
The closure f
is called with a free part of the buffer, it must write
some data to it and return the amount of bytes written.
sourcepub fn push_one(&mut self, val: u8) -> bool
pub fn push_one(&mut self, val: u8) -> bool
Push one data byte.
Returns true if pushed successfully.
sourcepub fn push_slice(&mut self) -> &mut [u8]
pub fn push_slice(&mut self) -> &mut [u8]
Get a buffer where data can be pushed to.
Equivalent to Self::push_buf
but returns a slice.
sourcepub fn push_slices(&mut self) -> [&mut [u8]; 2]
pub fn push_slices(&mut self) -> [&mut [u8]; 2]
Get up to two buffers where data can be pushed to.
Equivalent to Self::push_bufs
but returns slices.
sourcepub fn push_buf(&mut self) -> (*mut u8, usize)
pub fn push_buf(&mut self) -> (*mut u8, usize)
Get a buffer where data can be pushed to.
Write data to the start of the buffer, then call push_done
with
however many bytes you’ve pushed.
The buffer is suitable to DMA to.
If the ringbuf is full, size=0 will be returned.
The buffer stays valid as long as no other Writer
method is called
and init
/deinit
aren’t called on the ringbuf.
sourcepub fn push_bufs(&mut self) -> [(*mut u8, usize); 2]
pub fn push_bufs(&mut self) -> [(*mut u8, usize); 2]
Get up to two buffers where data can be pushed to.
Write data starting at the beginning of the first buffer, then call
push_done
with however many bytes you’ve pushed.
The buffers are suitable to DMA to.
If the ringbuf is full, both buffers will be zero length. If there is only area available, the second buffer will be zero length.
The buffer stays valid as long as no other Writer
method is called
and init
/deinit
aren’t called on the ringbuf.