#[cfg(feature = "futures-io")] mod futures; /// A compatibility layer for using non-tokio types with this crate. /// /// Example: /// ```no_run /// use smol::net::unix::UnixStream; /// use tokio_socks::{io::Compat, tcp::Socks5Stream}; /// let socket = Compat::new(UnixStream::connect(proxy_addr) /// .await /// .map_err(Error::Io)?); // Compat /// let conn = /// Socks5Stream::connect_with_password_and_socket(socket, target, username, password).await?; /// // Socks5Stream has implemented futures-io AsyncRead + AsyncWrite. /// ``` pub struct Compat(S); #[cfg(feature = "futures-io")] impl Compat { pub fn new(inner: S) -> Self { Compat(inner) } /// Consumes the `Compat``, returning the inner value. pub fn into_inner(self) -> S { self.0 } } #[cfg(feature = "futures-io")] impl AsRef for Compat { fn as_ref(&self) -> &S { &self.0 } } #[cfg(feature = "futures-io")] impl AsMut for Compat { fn as_mut(&mut self) -> &mut S { &mut self.0 } }