pub trait SendExt {
// Required methods
fn send(
&mut self,
data: &[u8],
header: Option<&[u8]>,
) -> Result<(), RingError>;
fn send_blocking(
&mut self,
data: &[u8],
header: Option<&[u8]>,
) -> Result<(), RingError>;
}
Expand description
A trait for high-level packet sending operations on XDP transmit sockets.
This trait provides methods to send packet data using an AF_XDP socket. It abstracts away the details of descriptor management and UMEM frame handling, offering a simple interface for non-blocking and blocking sends.
send
: Sends a packet in a non-blocking manner. You must ensure a frame is available by callingseek
orseek_n
before use.send_blocking
: Sends a packet and blocks until the kernel has processed the send.
§Arguments
data
- A byte slice containing the packet payload.header
- An optional byte slice for the packet header.
§Errors
Returns a RingError
if the send fails or if no frame is available.
§Example
use xdp_socket::{create_tx_socket, SendExt as _ };
let mut tx = create_tx_socket(...)?;
tx.send(b"hello", None)?;