use crate::{Bind, Connect, TcpListener, TcpStream};
use async_net_ as net;
use core::future::Future;
use core::task::{Context, Poll};
use futures_lite::{pin, FutureExt};
use std::io::Result;
use std::net::{Shutdown, SocketAddr};
impl TcpListener for net::TcpListener {
type Stream = net::TcpStream;
fn bind(addr: SocketAddr) -> Bind<Self> {
Bind::from(Self::bind(addr).boxed())
}
fn local_addr(&self) -> Result<SocketAddr> {
Self::local_addr(self)
}
fn poll_accept(&self, ctx: &mut Context) -> Poll<Result<(Self::Stream, SocketAddr)>> {
let fut = Self::accept(self);
pin!(fut);
fut.poll(ctx)
}
fn ttl(&self) -> Result<u32> {
Self::ttl(self)
}
fn set_ttl(&self, ttl: u32) -> Result<()> {
Self::set_ttl(self, ttl)
}
}
impl TcpStream for net::TcpStream {
fn connect(addr: SocketAddr) -> Connect<Self> {
Connect::from(Self::connect(addr).boxed())
}
fn local_addr(&self) -> Result<SocketAddr> {
Self::local_addr(self)
}
fn peer_addr(&self) -> Result<SocketAddr> {
Self::peer_addr(self)
}
fn shutdown(&self, how: Shutdown) -> Result<()> {
Self::shutdown(self, how)
}
fn nodelay(&self) -> Result<bool> {
Self::nodelay(self)
}
fn set_nodelay(&self, nodelay: bool) -> Result<()> {
Self::set_nodelay(self, nodelay)
}
fn ttl(&self) -> Result<u32> {
Self::ttl(self)
}
fn set_ttl(&self, ttl: u32) -> Result<()> {
Self::set_ttl(self, ttl)
}
}