@@ -477,7 +477,9 @@ impl InnerPostgresConnection {
477477}
478478
479479/// A connection to a Postgres database.
480- pub struct PostgresConnection ( Cell < InnerPostgresConnection > ) ;
480+ pub struct PostgresConnection {
481+ priv conn : Cell < InnerPostgresConnection >
482+ }
481483
482484impl PostgresConnection {
483485 /// Attempts to create a new connection to a Postgres database.
@@ -494,7 +496,9 @@ impl PostgresConnection {
494496 pub fn try_connect ( url : & str ) -> Result < PostgresConnection ,
495497 PostgresConnectError > {
496498 do InnerPostgresConnection :: try_connect ( url) . map_move |conn| {
497- PostgresConnection ( Cell :: new ( conn) )
499+ PostgresConnection {
500+ conn : Cell :: new ( conn)
501+ }
498502 }
499503 }
500504
@@ -511,9 +515,9 @@ impl PostgresConnection {
511515 /// Sets the notice handler for the connection, returning the old handler.
512516 pub fn set_notice_handler ( & self , handler : ~PostgresNoticeHandler )
513517 -> ~PostgresNoticeHandler {
514- let mut conn = self . take ( ) ;
518+ let mut conn = self . conn . take ( ) ;
515519 let handler = conn. set_notice_handler ( handler) ;
516- self . put_back ( conn) ;
520+ self . conn . put_back ( conn) ;
517521 handler
518522 }
519523
@@ -527,7 +531,7 @@ impl PostgresConnection {
527531 /// not outlive that connection.
528532 pub fn try_prepare < ' a > ( & ' a self , query : & str )
529533 -> Result < NormalPostgresStatement < ' a > , PostgresDbError > {
530- do self . with_mut_ref |conn| {
534+ do self . conn . with_mut_ref |conn| {
531535 conn. try_prepare ( query, self )
532536 }
533537 }
@@ -583,7 +587,7 @@ impl PostgresConnection {
583587 }
584588
585589 fn quick_query ( & self , query : & str ) {
586- do self . with_mut_ref |conn| {
590+ do self . conn . with_mut_ref |conn| {
587591 conn. write_messages ( [ & Query { query : query } ] ) ;
588592
589593 loop {
@@ -599,19 +603,19 @@ impl PostgresConnection {
599603 }
600604
601605 fn wait_for_ready ( & self ) {
602- do self . with_mut_ref |conn| {
606+ do self . conn . with_mut_ref |conn| {
603607 conn. wait_for_ready ( )
604608 }
605609 }
606610
607611 fn read_message ( & self ) -> BackendMessage {
608- do self . with_mut_ref |conn| {
612+ do self . conn . with_mut_ref |conn| {
609613 conn. read_message ( )
610614 }
611615 }
612616
613617 fn write_messages ( & self , messages : & [ & FrontendMessage ] ) {
614- do self . with_mut_ref |conn| {
618+ do self . conn . with_mut_ref |conn| {
615619 conn. write_messages ( messages)
616620 }
617621 }
@@ -649,13 +653,19 @@ impl<'self> PostgresTransaction<'self> {
649653 /// Like `PostgresConnection::try_prepare`.
650654 pub fn try_prepare < ' a > ( & ' a self , query : & str )
651655 -> Result < TransactionalPostgresStatement < ' a > , PostgresDbError > {
652- self . conn . try_prepare ( query) . map_move ( TransactionalPostgresStatement )
656+ do self . conn . try_prepare ( query) . map_move |stmt| {
657+ TransactionalPostgresStatement {
658+ stmt : stmt
659+ }
660+ }
653661 }
654662
655663 /// Like `PostgresConnection::prepare`.
656664 pub fn prepare < ' a > ( & ' a self , query : & str )
657665 -> TransactionalPostgresStatement < ' a > {
658- TransactionalPostgresStatement ( self . conn . prepare ( query) )
666+ TransactionalPostgresStatement {
667+ stmt : self . conn . prepare ( query)
668+ }
659669 }
660670
661671 /// Like `PostgresConnection::try_update`.
@@ -929,28 +939,30 @@ impl ResultDescription {
929939/// A statement prepared inside of a transaction.
930940///
931941/// Provides additional functionality over a `NormalPostgresStatement`.
932- pub struct TransactionalPostgresStatement < ' self > ( NormalPostgresStatement < ' self > ) ;
942+ pub struct TransactionalPostgresStatement < ' self > {
943+ priv stmt : NormalPostgresStatement < ' self >
944+ }
933945
934946impl < ' self > PostgresStatement for TransactionalPostgresStatement < ' self > {
935947 fn param_types < ' a > ( & ' a self ) -> & ' a [ PostgresType ] {
936- ( * * self ) . param_types ( )
948+ self . stmt . param_types ( )
937949 }
938950
939951 fn result_descriptions < ' a > ( & ' a self ) -> & ' a [ ResultDescription ] {
940- ( * * self ) . result_descriptions ( )
952+ self . stmt . result_descriptions ( )
941953 }
942954
943955 fn try_update ( & self , params : & [ & ToSql ] ) -> Result < uint , PostgresDbError > {
944- ( * * self ) . try_update ( params)
956+ self . stmt . try_update ( params)
945957 }
946958
947959 fn try_query < ' a > ( & ' a self , params : & [ & ToSql ] )
948960 -> Result < PostgresResult < ' a > , PostgresDbError > {
949- ( * * self ) . try_query ( params)
961+ self . stmt . try_query ( params)
950962 }
951963
952964 fn find_col_named ( & self , col : & str ) -> Option < uint > {
953- ( * * self ) . find_col_named ( col)
965+ self . stmt . find_col_named ( col)
954966 }
955967}
956968
@@ -966,7 +978,7 @@ impl<'self> TransactionalPostgresStatement<'self> {
966978 /// the parameters of the statement.
967979 pub fn try_lazy_query < ' a > ( & ' a self , row_limit : uint , params : & [ & ToSql ] )
968980 -> Result < PostgresResult < ' a > , PostgresDbError > {
969- ( * * self ) . try_lazy_query ( row_limit, params)
981+ self . stmt . try_lazy_query ( row_limit, params)
970982 }
971983
972984 /// A convenience wrapper around `try_lazy_query`.
0 commit comments