use std::{future::Future, io, net::SocketAddr};
use agnostic::RuntimeLite;
pub mod tcp;
#[cfg(feature = "tls")]
#[cfg_attr(docsrs, doc(cfg(feature = "tls")))]
pub mod tls;
pub trait Listener: Send + Sync + 'static {
type Stream: PromisedStream;
fn accept(&self) -> impl Future<Output = io::Result<(Self::Stream, SocketAddr)>> + Send;
fn local_addr(&self) -> SocketAddr;
fn shutdown(&self) -> impl Future<Output = io::Result<()>> + Send;
}
pub trait PromisedStream:
memberlist_core::transport::Connection + Unpin + Send + Sync + 'static
{
type Instant: agnostic::time::Instant + Send + Sync + 'static;
fn local_addr(&self) -> SocketAddr;
fn peer_addr(&self) -> SocketAddr;
}
pub trait StreamLayer: Send + Sync + 'static {
type Runtime: RuntimeLite;
type Listener: Listener<Stream = Self::Stream>;
type Stream: PromisedStream<Instant = <Self::Runtime as RuntimeLite>::Instant>;
type Options: Send + Sync + 'static;
fn new(options: Self::Options) -> impl Future<Output = io::Result<Self>> + Send
where
Self: Sized;
fn connect(&self, addr: SocketAddr) -> impl Future<Output = io::Result<Self::Stream>> + Send;
fn bind(&self, addr: SocketAddr) -> impl Future<Output = io::Result<Self::Listener>> + Send;
fn is_secure() -> bool;
}