@@ -23,7 +23,7 @@ impl MakeRustlsConnect {
23
23
24
24
impl < S > MakeTlsConnect < S > for MakeRustlsConnect
25
25
where
26
- S : AsyncRead + AsyncWrite + ' static
26
+ S : AsyncRead + AsyncWrite + Send + ' static
27
27
{
28
28
type Stream = TlsStream < S > ;
29
29
type TlsConnect = RustlsConnect ;
@@ -46,11 +46,11 @@ pub struct RustlsConnect {
46
46
47
47
impl < S > TlsConnect < S > for RustlsConnect
48
48
where
49
- S : AsyncRead + AsyncWrite + ' static
49
+ S : AsyncRead + AsyncWrite + Send + ' static
50
50
{
51
51
type Stream = TlsStream < S > ;
52
52
type Error = io:: Error ;
53
- type Future = Box < dyn Future < Item =( Self :: Stream , ChannelBinding ) , Error =Self :: Error > > ;
53
+ type Future = Box < dyn Future < Item =( Self :: Stream , ChannelBinding ) , Error =Self :: Error > + Send > ;
54
54
55
55
fn connect ( self , stream : S ) -> Self :: Future {
56
56
Box :: new (
59
59
)
60
60
}
61
61
}
62
+
63
+ #[ cfg( test) ]
64
+ mod tests {
65
+ use futures:: { Future , Stream } ;
66
+ use tokio:: runtime:: current_thread;
67
+
68
+ #[ test]
69
+ fn it_works ( ) {
70
+ let config = rustls:: ClientConfig :: new ( ) ;
71
+ let tls = super :: MakeRustlsConnect :: new ( config) ;
72
+ current_thread:: block_on_all (
73
+ tokio_postgres:: connect ( "sslmode=require host=localhost user=postgres" , tls)
74
+ . map ( |( client, connection) | {
75
+ tokio:: spawn (
76
+ connection. map_err ( |e| panic ! ( "{:?}" , e) )
77
+ ) ;
78
+ client
79
+ } )
80
+ . and_then ( |mut client| {
81
+ client. prepare ( "SELECT 1" )
82
+ . map ( |s| ( client, s) )
83
+ } )
84
+ . and_then ( |( mut client, statement) | {
85
+ client. query ( & statement, & [ ] ) . collect ( )
86
+ } )
87
+ ) . unwrap ( ) ;
88
+ }
89
+ }
0 commit comments