Trait SendExt

Source
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 calling seek or seek_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)?;

Required Methods§

Source

fn send(&mut self, data: &[u8], header: Option<&[u8]>) -> Result<(), RingError>

Source

fn send_blocking( &mut self, data: &[u8], header: Option<&[u8]>, ) -> Result<(), RingError>

Implementors§

Source§

impl SendExt for Socket<_TX>
where Socket<_TX>: Seek_<_TX> + Commit_<_TX> + PollWaitExt<_TX>,

An implementation block for the transmit socket (TxSocket) that provides high-level sending methods.