Trait pnet::datalink::DataLinkSender
source · pub trait DataLinkSender: Send {
// Required methods
fn build_and_send(
&mut self,
num_packets: usize,
packet_size: usize,
func: &mut dyn FnMut(&mut [u8])
) -> Option<Result<(), Error>>;
fn send_to(
&mut self,
packet: &[u8],
dst: Option<NetworkInterface>
) -> Option<Result<(), Error>>;
}
Expand description
Trait to enable sending $packet
packets.
Required Methods§
sourcefn build_and_send(
&mut self,
num_packets: usize,
packet_size: usize,
func: &mut dyn FnMut(&mut [u8])
) -> Option<Result<(), Error>>
fn build_and_send( &mut self, num_packets: usize, packet_size: usize, func: &mut dyn FnMut(&mut [u8]) ) -> Option<Result<(), Error>>
Create and send a number of packets.
This will call func
num_packets
times. The function will be provided with a
mutable packet to manipulate, which will then be sent. This allows packets to be
built in-place, avoiding the copy required for send
. If there is not sufficient
capacity in the buffer, None will be returned.
sourcefn send_to(
&mut self,
packet: &[u8],
dst: Option<NetworkInterface>
) -> Option<Result<(), Error>>
fn send_to( &mut self, packet: &[u8], dst: Option<NetworkInterface> ) -> Option<Result<(), Error>>
Send a packet.
This may require an additional copy compared to build_and_send
, depending on the
operating system being used. The second parameter is currently ignored, however
None
should be passed.