@@ -68,10 +68,12 @@ fn main() {
6868#[ feature( macro_rules, struct_variant, globs) ] ;
6969
7070extern mod extra;
71+ extern mod ssl = "github.com/sfackler/rust-ssl" ;
7172
7273use extra:: container:: Deque ;
7374use extra:: ringbuf:: RingBuf ;
7475use extra:: url:: { UserInfo , Url } ;
76+ use ssl:: SslStream ;
7577use std:: cell:: Cell ;
7678use std:: hashmap:: HashMap ;
7779use std:: rt:: io:: { Writer , io_error, Decorator } ;
@@ -379,8 +381,38 @@ fn open_socket(host: &str, port: Port)
379381 Err ( SocketError )
380382}
381383
384+ enum InternalStream {
385+ Normal ( TcpStream ) ,
386+ Ssl ( SslStream < TcpStream > )
387+ }
388+
389+ impl Reader for InternalStream {
390+ fn read ( & mut self , buf : & mut [ u8 ] ) -> Option < uint > {
391+ match * self {
392+ Normal ( ref mut s) => s. read ( buf) ,
393+ Ssl ( ref mut s) => s. read ( buf)
394+ }
395+ }
396+
397+ fn eof ( & mut self ) -> bool {
398+ match * self {
399+ Normal ( ref mut s) => s. eof ( ) ,
400+ Ssl ( ref mut s) => s. eof ( )
401+ }
402+ }
403+ }
404+
405+ impl Writer for InternalStream {
406+ fn write ( & mut self , buf : & [ u8 ] ) {
407+ match * self {
408+ Normal ( ref mut s) => s. write ( buf) ,
409+ Ssl ( ref mut s) => s. write ( buf)
410+ }
411+ }
412+ }
413+
382414struct InnerPostgresConnection {
383- stream : BufferedStream < TcpStream > ,
415+ stream : BufferedStream < InternalStream > ,
384416 next_stmt_id : int ,
385417 notice_handler : ~PostgresNoticeHandler ,
386418 notifications : RingBuf < PostgresNotification > ,
@@ -426,7 +458,7 @@ impl InnerPostgresConnection {
426458 } ;
427459
428460 let mut conn = InnerPostgresConnection {
429- stream : BufferedStream :: new ( stream) ,
461+ stream : BufferedStream :: new ( Normal ( stream) ) ,
430462 next_stmt_id : 0 ,
431463 notice_handler : ~DefaultNoticeHandler as ~PostgresNoticeHandler ,
432464 notifications : RingBuf :: new ( ) ,
@@ -1286,7 +1318,6 @@ impl RowIndex for int {
12861318}
12871319
12881320impl < ' self > RowIndex for & ' self str {
1289- #[ inline]
12901321 fn idx ( & self , stmt : & NormalPostgresStatement ) -> uint {
12911322 for ( i, desc) in stmt. result_descriptions ( ) . iter ( ) . enumerate ( ) {
12921323 if desc. name . as_slice ( ) == * self {
0 commit comments