1use futures::prelude::*;
2use futures::task::{Context, Poll};
3
4use std::fmt::Debug;
5use std::io;
6use std::net::SocketAddr;
7use std::pin::Pin;
8
9pub trait TcpStream: AsyncRead + AsyncWrite + Debug + Send {
11 fn poll_write_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>>;
13
14 fn poll_read_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>>;
16
17 fn take_error(&self) -> io::Result<Option<io::Error>>;
22
23 fn local_addr(&self) -> io::Result<SocketAddr>;
25
26 fn peer_addr(&self) -> io::Result<SocketAddr>;
28
29 fn shutdown(&self, how: std::net::Shutdown) -> std::io::Result<()>;
31
32 #[cfg(unix)]
34 fn as_raw_fd(&self) -> std::os::unix::io::RawFd;
35}
36
37pub trait TcpListener: Debug + Send {
39 fn local_addr(&self) -> io::Result<SocketAddr>;
41
42 fn poll_accept(
44 self: Pin<&mut Self>,
45 cx: &mut Context<'_>,
46 ) -> Poll<io::Result<Pin<Box<dyn TcpStream>>>>;
47
48 #[cfg(unix)]
50 fn as_raw_fd(&self) -> std::os::unix::io::RawFd;
51}