EthMRequest

Struct EthMRequest 

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

Provides methods for manipulating the EthPacket instances within an EthMRequest.

Source

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.

Source

pub fn from_iter( adapter_handle: HANDLE, iter: impl Iterator<Item = &'a mut IntermediateBuffer>, ) -> Self

Creates a new EthMRequest 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 to IntermediateBuffer.
§Returns

A new EthMRequest.

Source

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.

§Description

This function, drain_success, operates on mutable reference to the current instance of the struct. It returns an iterator that goes over each non-empty buffer in packets, in their original order, but only up to the index specified by packet_success. This iterator will yield Some(IntermediateBuffer) for each of these buffers. These buffers represent packets that have been successfully read from the driver.

Once called, this method drains the non-empty buffers from packets, up to packet_success making them empty (None).

§Returns

This function returns an implementation of Iterator trait. The iterator item type is a mutable reference to an IntermediateBuffer (&'a mut IntermediateBuffer). This iterator can be used to iterate over the drained buffers.

Source

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.

§Description

This function, drain, operates on mutable reference to the current instance of the struct. It returns an iterator which yields mutable references to IntermediateBuffer for each non-empty buffer in packets, and it yields them in the order they occur in packets.

Once called, this method drains the non-empty buffers from packets, making them empty (None).

§Returns

This function returns an implementation of Iterator trait. The iterator item type is a mutable reference to an IntermediateBuffer (&'a mut IntermediateBuffer). This iterator can be used to iterate over the drained buffers.

Source

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.

Source

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.

Source

pub fn get_packet_success(&self) -> u32

Returns the number of successfully processed packets

Source

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 the IntermediateBuffer to be added to the packets array.
§Returns
  • Ok(()) if the buffer was successfully added as a packet.
  • Err(ERROR_BUFFER_OVERFLOW.into()) if the packets array is full.
Source

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.

§Arguments
  • packets - An iterator yielding mutable references to IntermediateBuffer.
§Returns
  • Result indicating success or failure.

Auto Trait Implementations§

§

impl<'a, const N: usize> Freeze for EthMRequest<'a, N>

§

impl<'a, const N: usize> RefUnwindSafe for EthMRequest<'a, N>

§

impl<'a, const N: usize> !Send for EthMRequest<'a, N>

§

impl<'a, const N: usize> !Sync for EthMRequest<'a, N>

§

impl<'a, const N: usize> Unpin for EthMRequest<'a, N>

§

impl<'a, const N: usize> !UnwindSafe for EthMRequest<'a, 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.