pub use edge_nal::*;
pub trait NetStack {
type UdpBind<'a>: UdpBind
where
Self: 'a;
type UdpConnect<'a>: UdpConnect
where
Self: 'a;
type TcpBind<'a>: TcpBind
where
Self: 'a;
type TcpConnect<'a>: TcpConnect
where
Self: 'a;
type Dns<'a>: Dns
where
Self: 'a;
fn udp_bind(&self) -> Option<Self::UdpBind<'_>>;
fn udp_connect(&self) -> Option<Self::UdpConnect<'_>>;
fn tcp_bind(&self) -> Option<Self::TcpBind<'_>>;
fn tcp_connect(&self) -> Option<Self::TcpConnect<'_>>;
fn dns(&self) -> Option<Self::Dns<'_>>;
}
impl<T> NetStack for &T
where
T: NetStack,
{
type UdpBind<'a>
= T::UdpBind<'a>
where
Self: 'a;
type UdpConnect<'a>
= T::UdpConnect<'a>
where
Self: 'a;
type TcpBind<'a>
= T::TcpBind<'a>
where
Self: 'a;
type TcpConnect<'a>
= T::TcpConnect<'a>
where
Self: 'a;
type Dns<'a>
= T::Dns<'a>
where
Self: 'a;
fn udp_bind(&self) -> Option<Self::UdpBind<'_>> {
(*self).udp_bind()
}
fn udp_connect(&self) -> Option<Self::UdpConnect<'_>> {
(*self).udp_connect()
}
fn tcp_bind(&self) -> Option<Self::TcpBind<'_>> {
(*self).tcp_bind()
}
fn tcp_connect(&self) -> Option<Self::TcpConnect<'_>> {
(*self).tcp_connect()
}
fn dns(&self) -> Option<Self::Dns<'_>> {
(*self).dns()
}
}
#[cfg(feature = "std")]
pub mod std {
pub use edge_nal_std::*;
impl super::NetStack for Stack {
type UdpBind<'a>
= &'a Stack
where
Self: 'a;
type UdpConnect<'a>
= &'a Stack
where
Self: 'a;
type TcpBind<'a>
= &'a Stack
where
Self: 'a;
type TcpConnect<'a>
= &'a Stack
where
Self: 'a;
type Dns<'a>
= &'a Stack
where
Self: 'a;
fn udp_bind(&self) -> Option<Self::UdpBind<'_>> {
Some(self)
}
fn udp_connect(&self) -> Option<Self::UdpConnect<'_>> {
Some(self)
}
fn tcp_bind(&self) -> Option<Self::TcpBind<'_>> {
Some(self)
}
fn tcp_connect(&self) -> Option<Self::TcpConnect<'_>> {
Some(self)
}
fn dns(&self) -> Option<Self::Dns<'_>> {
Some(self)
}
}
}