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>

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 take_packet( &mut self, index: usize ) -> Option<&'a mut IntermediateBuffer>

Takes the IntermediateBuffer from the EthPacket at the specified index, replacing it with None.

This is useful when you want to use the packet’s buffer elsewhere, while ensuring that the EthMRequest no longer has access to it.

source

pub fn put_packet( &mut self, index: usize, buffer: &'a mut IntermediateBuffer ) -> Result<()>

Sets the IntermediateBuffer for the EthPacket at the specified index.

This method allows you to associate a new buffer with the EthPacket at the given index.

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 set_packet_number(&mut self, number: u32)

Sets the number of packets in the packets array.

This allows you to manually set the count of packets in the request.

source

pub fn reset(&mut self)

Resets the packet number to 0.

This effectively empties the request of packets.

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_INVALID_PARAMETER.into()) if the packets array is full.

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.