#[cfg(feature = "tokio")]
pub mod tokio;
use std::{
fmt, io,
net::{SocketAddr, TcpListener, TcpStream},
task::{Context, Poll},
};
use futures::{
future::BoxFuture,
io::{AsyncRead, AsyncWrite},
Stream,
};
use if_watch::{IfEvent, IpNet};
pub struct Incoming<S> {
pub stream: S,
pub local_addr: SocketAddr,
pub remote_addr: SocketAddr,
}
pub trait Provider: Clone + Send + 'static {
type Stream: AsyncRead + AsyncWrite + Send + Unpin + fmt::Debug;
type Listener: Send + Unpin;
type IfWatcher: Stream<Item = io::Result<IfEvent>> + Send + Unpin;
fn new_if_watcher() -> io::Result<Self::IfWatcher>;
fn addrs(_: &Self::IfWatcher) -> Vec<IpNet>;
fn new_listener(_: TcpListener) -> io::Result<Self::Listener>;
fn new_stream(_: TcpStream) -> BoxFuture<'static, io::Result<Self::Stream>>;
fn poll_accept(
_: &mut Self::Listener,
_: &mut Context<'_>,
) -> Poll<io::Result<Incoming<Self::Stream>>>;
}