@@ -66,7 +66,7 @@ use std::cell::{Cell, RefCell};
6666use std:: collections:: { VecDeque , HashMap } ;
6767use std:: fmt;
6868use std:: iter:: IntoIterator ;
69- use std:: io;
69+ use std:: io as std_io ;
7070use std:: io:: prelude:: * ;
7171use std:: mem;
7272use std:: slice;
@@ -79,7 +79,7 @@ use std::path::PathBuf;
7979pub use error:: { Error , ConnectError , SqlState , DbError , ErrorPosition } ;
8080#[ doc( inline) ]
8181pub use types:: { Oid , Type , Kind , ToSql , FromSql } ;
82- pub use io_util :: { SslMode , NegotiateSsl , StreamWrapper , NoSsl , Stream } ;
82+ use io :: { NoSsl , StreamWrapper , NegotiateSsl } ;
8383use types:: IsNull ;
8484#[ doc( inline) ]
8585pub use types:: Slice ;
@@ -93,9 +93,10 @@ use url::Url;
9393mod macros;
9494
9595mod error;
96- mod io_util ;
96+ pub mod io ;
9797mod message;
9898mod ugh_privacy;
99+ mod priv_io;
99100mod url;
100101mod util;
101102pub mod types;
@@ -390,7 +391,7 @@ pub fn cancel_query<T, N>(params: T, ssl: &mut SslMode<N>, data: CancelData)
390391 -> result:: Result < ( ) , ConnectError >
391392 where T : IntoConnectParams , N : NegotiateSsl {
392393 let params = try!( params. into_connect_params ( ) ) ;
393- let mut socket = try!( io_util :: initialize_stream ( & params, ssl) ) ;
394+ let mut socket = try!( priv_io :: initialize_stream ( & params, ssl) ) ;
394395
395396 try!( socket. write_message ( & CancelRequest {
396397 code : message:: CANCEL_CODE ,
@@ -456,6 +457,16 @@ impl IsolationLevel {
456457 }
457458}
458459
460+ /// Specifies the SSL support requested for a new connection.
461+ pub enum SslMode < N = NoSsl > {
462+ /// The connection will not use SSL.
463+ None ,
464+ /// The connection will use SSL if the backend supports it.
465+ Prefer ( N ) ,
466+ /// The connection must use SSL.
467+ Require ( N ) ,
468+ }
469+
459470#[ derive( Clone ) ]
460471struct CachedStatement {
461472 name : String ,
@@ -490,7 +501,7 @@ impl InnerConnection {
490501 -> result:: Result < InnerConnection , ConnectError >
491502 where T : IntoConnectParams , N : NegotiateSsl {
492503 let params = try!( params. into_connect_params ( ) ) ;
493- let stream = try!( io_util :: initialize_stream ( & params, ssl) ) ;
504+ let stream = try!( priv_io :: initialize_stream ( & params, ssl) ) ;
494505
495506 let ConnectParams { user, database, mut options, .. } = params;
496507
@@ -570,15 +581,15 @@ impl InnerConnection {
570581 }
571582 }
572583
573- fn write_messages ( & mut self , messages : & [ FrontendMessage ] ) -> io :: Result < ( ) > {
584+ fn write_messages ( & mut self , messages : & [ FrontendMessage ] ) -> std_io :: Result < ( ) > {
574585 debug_assert ! ( !self . desynchronized) ;
575586 for message in messages {
576587 try_desync ! ( self , self . stream. write_message( message) ) ;
577588 }
578589 Ok ( try_desync ! ( self , self . stream. flush( ) ) )
579590 }
580591
581- fn read_one_message ( & mut self ) -> io :: Result < Option < BackendMessage > > {
592+ fn read_one_message ( & mut self ) -> std_io :: Result < Option < BackendMessage > > {
582593 debug_assert ! ( !self . desynchronized) ;
583594 match try_desync ! ( self , self . stream. read_message( ) ) {
584595 NoticeResponse { fields } => {
@@ -595,15 +606,15 @@ impl InnerConnection {
595606 }
596607 }
597608
598- fn read_message_with_notification ( & mut self ) -> io :: Result < BackendMessage > {
609+ fn read_message_with_notification ( & mut self ) -> std_io :: Result < BackendMessage > {
599610 loop {
600611 if let Some ( msg) = try!( self . read_one_message ( ) ) {
601612 return Ok ( msg) ;
602613 }
603614 }
604615 }
605616
606- fn read_message ( & mut self ) -> io :: Result < BackendMessage > {
617+ fn read_message ( & mut self ) -> std_io :: Result < BackendMessage > {
607618 loop {
608619 match try!( self . read_message_with_notification ( ) ) {
609620 NotificationResponse { pid, channel, payload } => {
0 commit comments