use {
agave_xdp::transmitter::XdpSender,
std::{
fmt::{self, Debug},
io::{self},
net::SocketAddr,
},
};
#[derive(Debug)]
pub enum QuicSocket {
Xdp(QuicXdpSocketBundle),
Kernel(std::net::UdpSocket),
}
impl From<std::net::UdpSocket> for QuicSocket {
fn from(socket: std::net::UdpSocket) -> Self {
QuicSocket::Kernel(socket)
}
}
impl QuicSocket {
pub fn local_addr(&self) -> io::Result<SocketAddr> {
match self {
QuicSocket::Xdp(cfg) => cfg.socket.local_addr(),
QuicSocket::Kernel(socket) => socket.local_addr(),
}
}
}
pub struct QuicXdpSocketBundle {
pub socket: std::net::UdpSocket,
pub xdp_sender: XdpSender,
}
impl Debug for QuicXdpSocketBundle {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("QuicXdpSocketBundle")
.field("socket", &self.socket)
.finish()
}
}