DMAFrame

Struct DMAFrame 

Source
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>

Source

pub const fn new() -> Self

Creates a new node for the Serial DMA

Source

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.

Source

pub fn commit(&mut self, shrink_to: usize)

Used to shrink the current size of the frame, used in conjunction with write.

Source

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.

Source

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.

Source

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.

Source

pub fn clear(&mut self)

Clear the node of all data making it empty

Source

pub fn read(&self) -> &[u8]

Returns a readable slice which maps to the buffers internal data

Source

pub fn read_mut(&mut self) -> &mut [u8]

Returns a readable mutable slice which maps to the buffers internal data

Source

pub fn len(&self) -> usize

Reads how many bytes are available

Source

pub fn free(&self) -> usize

Reads how many bytes are free

Source

pub fn max_len(&self) -> usize

Get the max length of the frame

Source

pub fn is_empty(&self) -> bool

Checks if the frame is empty

Trait Implementations§

Source§

impl<const N: usize> AsRef<[u8]> for DMAFrame<N>

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<const N: usize> Debug for DMAFrame<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> Default for DMAFrame<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const N: usize> Write for DMAFrame<N>

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations§

§

impl<const N: usize> Freeze for DMAFrame<N>

§

impl<const N: usize> RefUnwindSafe for DMAFrame<N>

§

impl<const N: usize> Send for DMAFrame<N>

§

impl<const N: usize> Sync for DMAFrame<N>

§

impl<const N: usize> Unpin for DMAFrame<N>

§

impl<const N: usize> UnwindSafe for DMAFrame<N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.