pub struct DMAFrame<const N: usize> { /* private fields */ }Expand description
Data type for holding data frames for the Serial.
Internally used uninitialized storage, making this storage zero cost to create. It can also be
used with, for example, heapless::pool to create a pool of serial frames.
Implementations§
Source§impl<const N: usize> DMAFrame<N>
impl<const N: usize> DMAFrame<N>
Sourcepub fn write(&mut self) -> &mut [u8]
pub fn write(&mut self) -> &mut [u8]
Gives a &mut [u8] slice to write into with the maximum size, the commit method
must then be used to set the actual number of bytes written.
Note that this function internally first zeros the uninitialized part of the node’s buffer.
Sourcepub fn commit(&mut self, shrink_to: usize)
pub fn commit(&mut self, shrink_to: usize)
Used to shrink the current size of the frame, used in conjunction with write.
Sourcepub fn write_uninit(&mut self) -> &mut [MaybeUninit<u8>; N]
pub fn write_uninit(&mut self) -> &mut [MaybeUninit<u8>; N]
Gives an uninitialized &mut [MaybeUninit<u8>] slice to write into, the set_len method
must then be used to set the actual number of bytes written.
Sourcepub unsafe fn set_len(&mut self, len: usize)
pub unsafe fn set_len(&mut self, len: usize)
Used to set the current size of the frame, used in conjunction with write_uninit to have an
interface for uninitialized memory. Use with care!
§Safety
NOTE(unsafe): This must be set so that the final buffer is only referencing initialized memory.
Sourcepub fn write_slice(&mut self, buf: &[u8]) -> usize
pub fn write_slice(&mut self, buf: &[u8]) -> usize
Used to write data into the node, and returns how many bytes were written from buf.
If the node is already partially filled, this will continue filling the node.