@@ -421,10 +421,7 @@ impl InnerPostgresConnection {
421421}
422422
423423/// A connection to a Postgres database.
424- // FIXME should be a newtype
425- pub struct PostgresConnection {
426- priv conn : Cell < InnerPostgresConnection >
427- }
424+ pub struct PostgresConnection ( Cell < InnerPostgresConnection > ) ;
428425
429426impl PostgresConnection {
430427 /// Attempts to create a new connection to a Postgres database.
@@ -441,7 +438,7 @@ impl PostgresConnection {
441438 pub fn try_connect ( url : & str ) -> Result < PostgresConnection ,
442439 PostgresConnectError > {
443440 do InnerPostgresConnection :: try_connect ( url) . map_move |conn| {
444- PostgresConnection { conn : Cell :: new ( conn) }
441+ PostgresConnection ( Cell :: new ( conn) )
445442 }
446443 }
447444
@@ -458,9 +455,9 @@ impl PostgresConnection {
458455 /// Sets the notice handler for the connection, returning the old handler.
459456 pub fn set_notice_handler ( & self , handler : ~PostgresNoticeHandler )
460457 -> ~PostgresNoticeHandler {
461- let mut conn = self . conn . take ( ) ;
458+ let mut conn = self . take ( ) ;
462459 let handler = conn. set_notice_handler ( handler) ;
463- self . conn . put_back ( conn) ;
460+ self . put_back ( conn) ;
464461 handler
465462 }
466463
@@ -474,7 +471,7 @@ impl PostgresConnection {
474471 /// not outlive that connection.
475472 pub fn try_prepare < ' a > ( & ' a self , query : & str )
476473 -> Result < NormalPostgresStatement < ' a > , PostgresDbError > {
477- do self . conn . with_mut_ref |conn| {
474+ do self . with_mut_ref |conn| {
478475 conn. try_prepare ( query, self )
479476 }
480477 }
@@ -530,7 +527,7 @@ impl PostgresConnection {
530527 }
531528
532529 fn quick_query ( & self , query : & str ) {
533- do self . conn . with_mut_ref |conn| {
530+ do self . with_mut_ref |conn| {
534531 conn. write_messages ( [ & Query { query : query } ] ) ;
535532
536533 loop {
@@ -546,19 +543,19 @@ impl PostgresConnection {
546543 }
547544
548545 fn wait_for_ready ( & self ) {
549- do self . conn . with_mut_ref |conn| {
546+ do self . with_mut_ref |conn| {
550547 conn. wait_for_ready ( )
551548 }
552549 }
553550
554551 fn read_message ( & self ) -> BackendMessage {
555- do self . conn . with_mut_ref |conn| {
552+ do self . with_mut_ref |conn| {
556553 conn. read_message ( )
557554 }
558555 }
559556
560557 fn write_messages ( & self , messages : & [ & FrontendMessage ] ) {
561- do self . conn . with_mut_ref |conn| {
558+ do self . with_mut_ref |conn| {
562559 conn. write_messages ( messages)
563560 }
564561 }
0 commit comments