pub struct EthMRequestMut<'a, const N: usize> { /* private fields */ }Expand description
This structure represents a request for multiple Ethernet packets, containing a network adapter handle, packet number, packet success count, and an array of EthPacketMut instances.
A Rust equivalent for the _ETH_M_REQUEST structure.
adapter_handle is a handle to the network adapter associated with this request. packet_number is the number of packets in the packets array. packet_success is the number of packets that have been successfully processed. packets is an array of EthPacketMut instances representing the Ethernet packets for this request.
Implementations§
Source§impl<'a, const N: usize> EthMRequestMut<'a, N>
Provides methods for manipulating the EthPacketMut instances within an EthMRequestMut.
impl<'a, const N: usize> EthMRequestMut<'a, N>
Provides methods for manipulating the EthPacketMut instances within an EthMRequestMut.
Sourcepub fn new(adapter_handle: HANDLE) -> Self
pub fn new(adapter_handle: HANDLE) -> Self
Creates a new EthMRequestMut with the specified adapter handle.
All packets in the request are initialized to empty.
Sourcepub fn from_iter(
adapter_handle: HANDLE,
iter: impl Iterator<Item = &'a mut IntermediateBuffer>,
) -> Self
pub fn from_iter( adapter_handle: HANDLE, iter: impl Iterator<Item = &'a mut IntermediateBuffer>, ) -> Self
Creates a new EthMRequestMut from an iterator over &mut IntermediateBuffer.
This constructor will attempt to consume up to N items from the iterator to initialize the packets array.
If the iterator contains fewer than N items, the remaining entries in the packets array will be left as None.
§Arguments
adapter_handle: A handle to the network adapter associated with this request.iter: An iterator over mutable references toIntermediateBuffer.
§Returns
A new EthMRequestMut.
Sourcepub fn drain_success(
&mut self,
) -> impl Iterator<Item = &'a mut IntermediateBuffer> + '_
pub fn drain_success( &mut self, ) -> impl Iterator<Item = &'a mut IntermediateBuffer> + '_
Returns an iterator that yields Some(IntermediateBuffer) for each non-empty buffer in packets, in order,
up to packet_success.
This method is used to drain the successful packets from the request. It iterates over the packets in the request,
and for each packet that has a buffer (i.e., is not empty), it decreases the packet number and removes the buffer from the packet.
The removed buffer (which is a mutable reference to an IntermediateBuffer) is then yielded by the iterator.
This process continues until either all packets have been inspected or a number of packets equal to packet_success have been drained.
§Returns
An iterator over Option<&'a mut IntermediateBuffer>. Each Some(IntermediateBuffer) item in the iterator represents a successfully processed packet.
Sourcepub fn drain(&mut self) -> impl Iterator<Item = &'a mut IntermediateBuffer> + '_
pub fn drain(&mut self) -> impl Iterator<Item = &'a mut IntermediateBuffer> + '_
Returns an iterator that yields Some(IntermediateBuffer) for each non-empty buffer in packets.
This method is used to drain the packets from the request. It iterates over the packets in the request,
and for each packet that has a buffer (i.e., is not empty), it decreases the packet number and removes the buffer from the packet.
The removed buffer (which is a mutable reference to an IntermediateBuffer) is then yielded by the iterator.
§Returns
An iterator over Option<&'a mut IntermediateBuffer>. Each Some(IntermediateBuffer) item in the iterator represents a packet.
Sourcepub fn get_packet_number(&self) -> u32
pub fn get_packet_number(&self) -> u32
Returns the number of packets in the packets array.
This method is used to get the total number of packets currently stored in the packets array.
The packets array is used to store the packets that are to be sent or received.
§Returns
A u32 value representing the total number of packets in the packets array.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Erases all EthPacketMut instances within the packets array and releases all references.
This method is used to reset the state of the EthMRequest instance. It iterates over the packets array,
setting each buffer field to None, effectively releasing all references to IntermediateBuffer instances.
It also resets the packet_number and packet_success counters to 0.
Sourcepub fn get_packet_success(&self) -> u32
pub fn get_packet_success(&self) -> u32
Returns the number of successfully processed packets.
This method is used to get the total number of packets that have been successfully processed.
The packet_success field is incremented each time a packet is successfully processed.
§Returns
A u32 value representing the total number of successfully processed packets.
Sourcepub fn push(&mut self, packet: &'a mut IntermediateBuffer) -> Result<()>
pub fn push(&mut self, packet: &'a mut IntermediateBuffer) -> Result<()>
Adds an IntermediateBuffer to the packets array if there’s available space.
This method is used to add a new packet to the packets array. It first checks if the current number of packets
is less than the maximum allowed (N). If there is space available, it finds the first empty slot in the packets
array and inserts the new packet there, incrementing the packet_number counter. If the packets array is full,
it returns an Err with ERROR_BUFFER_OVERFLOW.
§Arguments
packet: A mutable reference to anIntermediateBufferrepresenting the new packet to be added.
§Returns
Ok(())if the packet was successfully added.Err(ERROR_BUFFER_OVERFLOW.into())if thepacketsarray is full.
Sourcepub fn append<I>(&mut self, packets: I) -> Result<()>where
I: Iterator<Item = &'a mut IntermediateBuffer>,
pub fn append<I>(&mut self, packets: I) -> Result<()>where
I: Iterator<Item = &'a mut IntermediateBuffer>,
Consumes packets from an Iterator, moving them into self.
This method is used to add packets from an iterator to the packets array. It iterates over the packets provided by the iterator,
and for each packet, it checks if there is space available in the packets array. If there is space available, it finds the first empty slot
in the packets array and inserts the new packet there, incrementing the packet_number counter. If the packets array is full,
it returns an Err with ERROR_BUFFER_OVERFLOW.
§Arguments
packets: An iterator that yields mutable references toIntermediateBufferinstances.
§Returns
Ok(())if all packets from the iterator were successfully added.Err(ERROR_BUFFER_OVERFLOW.into())if thepacketsarray is full.