@@ -205,7 +205,7 @@ pub type PostgresResult<T> = Result<T, PostgresError>;
205205#[ deriving( Clone ) ]
206206pub enum PostgresConnectTarget {
207207 /// Connect via TCP to the specified host.
208- TargetTcp ( ~ str ) ,
208+ TargetTcp ( StrBuf ) ,
209209 /// Connect via a Unix domain socket in the specified directory.
210210 TargetUnix ( Path )
211211}
@@ -223,13 +223,13 @@ pub struct PostgresConnectParams {
223223 ///
224224 /// `PostgresConnection::connect` requires a user but `cancel_query` does
225225 /// not.
226- pub user : Option < ~ str > ,
226+ pub user : Option < StrBuf > ,
227227 /// An optional password used for authentication
228- pub password : Option < ~ str > ,
228+ pub password : Option < StrBuf > ,
229229 /// The database to connect to. Defaults the value of `user`.
230- pub database : Option < ~ str > ,
230+ pub database : Option < StrBuf > ,
231231 /// Runtime parameters to be passed to the Postgres backend.
232- pub options : Vec < ( ~ str , ~ str ) > ,
232+ pub options : Vec < ( StrBuf , StrBuf ) > ,
233233}
234234
235235/// A trait implemented by types that can be converted into a
@@ -262,8 +262,8 @@ impl<'a> IntoConnectParams for &'a str {
262262 Err ( err) => return Err ( InvalidUrl ( err) )
263263 } ;
264264
265- let maybe_path = url:: decode_component ( host) ;
266- let target = if maybe_path. starts_with ( "/" ) {
265+ let maybe_path = url:: decode_component ( host. as_slice ( ) ) ;
266+ let target = if maybe_path. as_slice ( ) . starts_with ( "/" ) {
267267 TargetUnix ( Path :: new ( maybe_path) )
268268 } else {
269269 TargetTcp ( host)
@@ -275,17 +275,17 @@ impl<'a> IntoConnectParams for &'a str {
275275 } ;
276276
277277 let port = match port {
278- Some ( port) => match FromStr :: from_str ( port) {
278+ Some ( port) => match FromStr :: from_str ( port. as_slice ( ) ) {
279279 Some ( port) => Some ( port) ,
280- None => return Err ( InvalidUrl ( "invalid port" . to_owned ( ) ) ) ,
280+ None => return Err ( InvalidUrl ( "invalid port" . to_strbuf ( ) ) ) ,
281281 } ,
282282 None => None ,
283283 } ;
284284
285285 let database = if !path. is_empty ( ) {
286286 // path contains the leading /
287- let ( _, path) = path. slice_shift_char ( ) ;
288- Some ( path. to_owned ( ) )
287+ let ( _, path) = path. as_slice ( ) . slice_shift_char ( ) ;
288+ Some ( path. to_strbuf ( ) )
289289 } else {
290290 None
291291 } ;
@@ -451,14 +451,14 @@ impl InnerPostgresConnection {
451451 None => return Err ( MissingUser ) ,
452452 } ;
453453
454- options. push ( ( "client_encoding" . to_owned ( ) , "UTF8" . to_owned ( ) ) ) ;
454+ options. push ( ( "client_encoding" . to_strbuf ( ) , "UTF8" . to_strbuf ( ) ) ) ;
455455 // Postgres uses the value of TimeZone as the time zone for TIMESTAMP
456456 // WITH TIME ZONE values. Timespec converts to GMT internally.
457- options. push ( ( "TimeZone" . to_owned ( ) , "GMT" . to_owned ( ) ) ) ;
457+ options. push ( ( "TimeZone" . to_strbuf ( ) , "GMT" . to_strbuf ( ) ) ) ;
458458 // We have to clone here since we need the user again for auth
459- options. push ( ( "user" . to_owned ( ) , user. clone ( ) ) ) ;
459+ options. push ( ( "user" . to_strbuf ( ) , user. clone ( ) ) ) ;
460460 match database {
461- Some ( database) => options. push ( ( "database" . to_owned ( ) , database) ) ,
461+ Some ( database) => options. push ( ( "database" . to_strbuf ( ) , database) ) ,
462462 None => { }
463463 }
464464
@@ -513,7 +513,7 @@ impl InnerPostgresConnection {
513513 }
514514 }
515515
516- fn handle_auth ( & mut self , user : ~ str , pass : Option < ~ str > )
516+ fn handle_auth ( & mut self , user : StrBuf , pass : Option < StrBuf > )
517517 -> Result < ( ) , PostgresConnectError > {
518518 match try_pg_conn ! ( self . read_message( ) ) {
519519 AuthenticationOk => return Ok ( ( ) ) ,
@@ -523,7 +523,7 @@ impl InnerPostgresConnection {
523523 None => return Err ( MissingPassword )
524524 } ;
525525 try_pg_conn ! ( self . write_messages( [ PasswordMessage {
526- password: pass
526+ password: pass. as_slice ( ) ,
527527 } ] ) ) ;
528528 }
529529 AuthenticationMD5Password { salt } => {
0 commit comments