Struct embassy_stm32::eth::PacketQueue
source · pub struct PacketQueue<const TX: usize, const RX: usize> { /* private fields */ }
Expand description
Ethernet packet queue.
This struct owns the memory used for reading and writing packets.
TX
is the number of packets in the transmit queue, RX
in the receive
queue. A bigger queue allows the hardware to receive more packets while the
CPU is busy doing other things, which may increase performance (especially for RX)
at the cost of more RAM usage.
Implementations§
source§impl<const TX: usize, const RX: usize> PacketQueue<TX, RX>
impl<const TX: usize, const RX: usize> PacketQueue<TX, RX>
sourcepub fn init(this: &mut MaybeUninit<Self>)
pub fn init(this: &mut MaybeUninit<Self>)
Initialize a packet queue in-place.
This can be helpful to avoid accidentally stack-allocating the packet queue in the stack. The
Rust compiler can sometimes be a bit dumb when working with large owned values: if you call new()
and then store the returned PacketQueue in its final place (like a static
), the compiler might
place it temporarily on the stack then move it. Since this struct is quite big, it may result
in a stack overflow.
With this function, you can create an uninitialized static
with type MaybeUninit<PacketQueue<...>>
and initialize it in-place, guaranteeing no stack usage.
After calling this function, calling assume_init
on the MaybeUninit is guaranteed safe.