Struct ndisapi_rs::EthMRequest
source · #[repr(C)]pub struct EthMRequest<'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 EthPacket
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 EthPacket
instances representing the Ethernet packets for this request.
Implementations§
source§impl<'a, const N: usize> EthMRequest<'a, N>
impl<'a, const N: usize> EthMRequest<'a, N>
Provides methods for manipulating the EthPacket
instances within an EthMRequest
.
sourcepub fn new(adapter_handle: HANDLE) -> Self
pub fn new(adapter_handle: HANDLE) -> Self
Creates a new EthMRequest
with the specified adapter handle.
All packets in the request are initialized to empty.
sourcepub fn drain_success_packets(
&mut self
) -> impl Iterator<Item = &'a mut IntermediateBuffer> + '_
pub fn drain_success_packets( &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
.
Once called, this method “drains” the non-empty buffers from packets
, leaving them empty.
sourcepub fn get_packet_number(&self) -> u32
pub fn get_packet_number(&self) -> u32
Returns the number of packets in the packets
array.
This provides a count of all packets, regardless of whether they’ve been successfully processed.
sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Erases all EthPacket
instances within the packets
array and releases all references.
After this method is called, all EthPacket
instances within the packets
array will be empty (i.e., their buffer
fields will be None
), and the packet number will be reset to 0.
sourcepub fn get_packet_success(&self) -> u32
pub fn get_packet_success(&self) -> u32
Returns the 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 effectively wraps the buffer into an EthPacket
and stores it in the array.
The packet_number
field of the EthMRequest
is automatically incremented to reflect the addition of the new packet.
If there is no available space in the array (i.e., if the packet_number
is equal to the array length N
), this method returns an error, specifically ERROR_INVALID_PARAMETER
.
This method provides an idiomatic way of adding new packets to an EthMRequest
in Rust.
Arguments
packet
- A mutable reference to theIntermediateBuffer
to be added to thepackets
array.
Returns
Ok(())
if the buffer was successfully added as a packet.Err(ERROR_BUFFER_OVERFLOW.into())
if thepackets
array is full.