@@ -61,10 +61,12 @@ use std::ascii::AsciiExt;
6161use std:: borrow:: ToOwned ;
6262use std:: cell:: { Cell , RefCell } ;
6363use std:: collections:: { VecDeque , HashMap } ;
64+ use std:: error:: Error as StdError ;
6465use std:: fmt;
6566use std:: iter:: IntoIterator ;
6667use std:: io as std_io;
6768use std:: io:: prelude:: * ;
69+ use std:: marker:: Sync as StdSync ;
6870use std:: mem;
6971use std:: result;
7072#[ cfg( feature = "unix_socket" ) ]
@@ -145,26 +147,26 @@ pub struct ConnectParams {
145147/// A trait implemented by types that can be converted into a `ConnectParams`.
146148pub trait IntoConnectParams {
147149 /// Converts the value of `self` into a `ConnectParams`.
148- fn into_connect_params ( self ) -> result:: Result < ConnectParams , ConnectError > ;
150+ fn into_connect_params ( self ) -> result:: Result < ConnectParams , Box < StdError + StdSync + Send > > ;
149151}
150152
151153impl IntoConnectParams for ConnectParams {
152- fn into_connect_params ( self ) -> result:: Result < ConnectParams , ConnectError > {
154+ fn into_connect_params ( self ) -> result:: Result < ConnectParams , Box < StdError + StdSync + Send > > {
153155 Ok ( self )
154156 }
155157}
156158
157159impl < ' a > IntoConnectParams for & ' a str {
158- fn into_connect_params ( self ) -> result:: Result < ConnectParams , ConnectError > {
160+ fn into_connect_params ( self ) -> result:: Result < ConnectParams , Box < StdError + StdSync + Send > > {
159161 match Url :: parse ( self ) {
160162 Ok ( url) => url. into_connect_params ( ) ,
161- Err ( err) => return Err ( ConnectError :: InvalidUrl ( err) ) ,
163+ Err ( err) => return Err ( err. into ( ) ) ,
162164 }
163165 }
164166}
165167
166168impl IntoConnectParams for Url {
167- fn into_connect_params ( self ) -> result:: Result < ConnectParams , ConnectError > {
169+ fn into_connect_params ( self ) -> result:: Result < ConnectParams , Box < StdError + StdSync + Send > > {
168170 let Url {
169171 host,
170172 port,
@@ -174,16 +176,16 @@ impl IntoConnectParams for Url {
174176 } = self ;
175177
176178 #[ cfg( feature = "unix_socket" ) ]
177- fn make_unix ( maybe_path : String ) -> result:: Result < ConnectTarget , ConnectError > {
179+ fn make_unix ( maybe_path : String )
180+ -> result:: Result < ConnectTarget , Box < StdError +StdSync +Send > > {
178181 Ok ( ConnectTarget :: Unix ( PathBuf :: from ( maybe_path) ) )
179182 }
180183 #[ cfg( not( feature = "unix_socket" ) ) ]
181- fn make_unix ( _: String ) -> result:: Result < ConnectTarget , ConnectError > {
182- Err ( ConnectError :: InvalidUrl ( "unix socket support requires the `unix_socket` feature"
183- . to_string ( ) ) )
184+ fn make_unix ( _: String ) -> result:: Result < ConnectTarget , Box < StdError +StdSync +Send > > {
185+ Err ( "unix socket support requires the `unix_socket` feature" . into ( ) )
184186 }
185187
186- let maybe_path = try!( url:: decode_component ( & host) . map_err ( ConnectError :: InvalidUrl ) ) ;
188+ let maybe_path = try!( url:: decode_component ( & host) ) ;
187189 let target = if maybe_path. starts_with ( "/" ) {
188190 try!( make_unix ( maybe_path) )
189191 } else {
@@ -330,7 +332,7 @@ pub struct CancelData {
330332pub fn cancel_query < T > ( params : T , ssl : & SslMode , data : CancelData )
331333 -> result:: Result < ( ) , ConnectError >
332334 where T : IntoConnectParams {
333- let params = try!( params. into_connect_params ( ) ) ;
335+ let params = try!( params. into_connect_params ( ) . map_err ( ConnectError :: BadConnectParams ) ) ;
334336 let mut socket = try!( priv_io:: initialize_stream ( & params, ssl) ) ;
335337
336338 try!( socket. write_message ( & CancelRequest {
@@ -459,7 +461,7 @@ impl Drop for InnerConnection {
459461impl InnerConnection {
460462 fn connect < T > ( params : T , ssl : & SslMode ) -> result:: Result < InnerConnection , ConnectError >
461463 where T : IntoConnectParams {
462- let params = try!( params. into_connect_params ( ) ) ;
464+ let params = try!( params. into_connect_params ( ) . map_err ( ConnectError :: BadConnectParams ) ) ;
463465 let stream = try!( priv_io:: initialize_stream ( & params, ssl) ) ;
464466
465467 let ConnectParams { user, database, mut options, .. } = params;
0 commit comments