title: Opening tls stream for rabbit client using rust amiquip
body: <p>I'm trying to enable the TLS feature to Open an encrypted AMQP connection on a stream.
  In the amiquip crate docs, there's an example <a href="https://docs.rs/amiquip/0.3.0/amiquip/struct.Connection.html#examples" rel="nofollow noreferrer">https://docs.rs/amiquip/0.3.0/amiquip/struct.Connection.html#examples</a></p>
  <p>I copied the code example and implement the <code>tcp_stream</code> function requested as simple as possible to just return the <code>mio::net::TcpStream</code> instance as said.</p>
  <pre><code>use amiquip::{Auth, Connection, ConnectionOptions, ConnectionTuning, Result};
  use mio::net::TcpStream;
  use std::net::SocketAddr;
  use std::{io::Read, time::Duration};
  
  // Examples below assume a helper function to open a TcpStream from an address string with
  // a signature like this is available:
  fn tcp_stream() -&gt; mio::net::TcpStream {
      let address: SocketAddr = &quot;127.0.0.0:5671&quot;.parse().unwrap();
      mio::net::TcpStream::connect(address).unwrap()
  }
  
  fn main() -&gt; Result&lt;()&gt; {
      // Empty amqp URL is equivalent to default options; handy for initial debugging and
      // development.
      // let temp = Connection::open_tls_stream(connector, domain, stream, options, tuning)
      let conn1 = Connection::insecure_open(&quot;amqp://&quot;)?;
      let conn1 = Connection::insecure_open_stream(
          tcp_stream(),
          ConnectionOptions::&lt;Auth&gt;::default(),
          ConnectionTuning::default(),
      )?;
  
      // All possible options specified in the URL except auth_mechanism=external (which would
      // override the username and password).
      let conn3 = Connection::insecure_open(
          &quot;amqp://user:pass@example.com:12345/myvhost?heartbeat=30&amp;channel_max=1024&amp;connection_timeout=10000&quot;,
      )?;
      let conn3 = Connection::insecure_open_stream(
          tcp_stream(),
          ConnectionOptions::default()
              .auth(Auth::Plain {
                  username: &quot;user&quot;.to_string(),
                  password: &quot;pass&quot;.to_string(),
              })
              .heartbeat(30)
              .channel_max(1024)
              .connection_timeout(Some(Duration::from_millis(10_000))),
          ConnectionTuning::default(),
      )?;
      Ok(())
  }
  </code></pre>
  <p>However, I get compilation error (on every version of the crate) as following</p>
  <pre><code>error[E0277]: the trait bound `mio::net::TcpStream: IoStream` is not satisfied
     --&gt; src\main.rs:28:17
      |
  28  |     let conn3 = Connection::insecure_open_stream(
      |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IoStream` is not implemented for `mio::net::TcpStream`
      | 
     ::: C:\Users\Tamir Cohen\.cargo\registry\src\github.com-1ecc6299db9ec823\amiquip-0.3.3\src\connection.rs:283:48
      |
  283 |     pub fn insecure_open_stream&lt;Auth: Sasl, S: IoStream&gt;(
      |                                                -------- required by this bound in `Connection::insecure_open_stream`
  </code></pre>
  <p>and I just can't figure out what went wrong.</p>