@@ -9,14 +9,7 @@ use std::default::Default;
99use std:: fmt;
1010use std:: mem;
1111use std:: rc:: Rc ;
12- use postgres:: { PostgresConnection ,
13- PostgresConnectParams ,
14- IntoConnectParams ,
15- SslMode ,
16- PostgresResult ,
17- PostgresStatement ,
18- PostgresCopyInStatement ,
19- PostgresTransaction } ;
12+ use postgres:: { IntoConnectParams , SslMode } ;
2013use postgres:: error:: { PostgresConnectError , PostgresError } ;
2114use postgres:: types:: ToSql ;
2215
@@ -35,7 +28,7 @@ impl fmt::Show for Error {
3528}
3629
3730pub struct PostgresPoolManager {
38- params : Result < PostgresConnectParams , PostgresConnectError > ,
31+ params : Result < postgres :: ConnectParams , PostgresConnectError > ,
3932 ssl_mode : SslMode ,
4033}
4134
@@ -48,21 +41,21 @@ impl PostgresPoolManager {
4841 }
4942}
5043
51- impl r2d2:: PoolManager < PostgresConnection , Error > for PostgresPoolManager {
52- fn connect ( & self ) -> Result < PostgresConnection , Error > {
44+ impl r2d2:: PoolManager < postgres :: Connection , Error > for PostgresPoolManager {
45+ fn connect ( & self ) -> Result < postgres :: Connection , Error > {
5346 match self . params {
5447 Ok ( ref p) => {
55- PostgresConnection :: connect ( p. clone ( ) , & self . ssl_mode ) . map_err ( ConnectError )
48+ postgres :: Connection :: connect ( p. clone ( ) , & self . ssl_mode ) . map_err ( ConnectError )
5649 }
5750 Err ( ref e) => Err ( ConnectError ( e. clone ( ) ) )
5851 }
5952 }
6053
61- fn is_valid ( & self , conn : & mut PostgresConnection ) -> Result < ( ) , Error > {
54+ fn is_valid ( & self , conn : & mut postgres :: Connection ) -> Result < ( ) , Error > {
6255 conn. batch_execute ( "" ) . map_err ( OtherError )
6356 }
6457
65- fn has_broken ( & self , conn : & mut PostgresConnection ) -> bool {
58+ fn has_broken ( & self , conn : & mut postgres :: Connection ) -> bool {
6659 conn. is_desynchronized ( )
6760 }
6861}
@@ -96,7 +89,7 @@ impl StatementCachingManager {
9689
9790impl r2d2:: PoolManager < Connection , Error > for StatementCachingManager {
9891 fn connect ( & self ) -> Result < Connection , Error > {
99- let cache = box RefCell :: new ( LruCache :: < String , PostgresStatement < ' static > > :: new (
92+ let cache = box RefCell :: new ( LruCache :: < String , postgres :: Statement < ' static > > :: new (
10093 self . config . statement_pool_size ) ) ;
10194 Ok ( Connection {
10295 conn : box try!( self . manager . connect ( ) ) ,
@@ -114,45 +107,45 @@ impl r2d2::PoolManager<Connection, Error> for StatementCachingManager {
114107}
115108
116109pub trait GenericConnection {
117- /// Like `PostgresConnection ::prepare`.
118- fn prepare < ' a > ( & ' a self , query : & str ) -> PostgresResult < Rc < PostgresStatement < ' a > > > ;
110+ /// Like `postgres::Connection ::prepare`.
111+ fn prepare < ' a > ( & ' a self , query : & str ) -> postgres :: Result < Rc < postgres :: Statement < ' a > > > ;
119112
120- /// Like `PostgresConnection ::execute`.
121- fn execute ( & self , query : & str , params : & [ & ToSql ] ) -> PostgresResult < uint > {
113+ /// Like `postgres::Connection ::execute`.
114+ fn execute ( & self , query : & str , params : & [ & ToSql ] ) -> postgres :: Result < uint > {
122115 self . prepare ( query) . and_then ( |s| s. execute ( params) )
123116 }
124117
125- /// Like `PostgresConnection ::prepare_copy_in`.
118+ /// Like `postgres::Connection ::prepare_copy_in`.
126119 fn prepare_copy_in < ' a > ( & ' a self , table : & str , columns : & [ & str ] )
127- -> PostgresResult < PostgresCopyInStatement < ' a > > ;
120+ -> postgres :: Result < postgres :: CopyInStatement < ' a > > ;
128121
129- /// Like `PostgresConnection ::transaction`.
130- fn transaction < ' a > ( & ' a self ) -> PostgresResult < Transaction < ' a > > ;
122+ /// Like `postgres::Connection ::transaction`.
123+ fn transaction < ' a > ( & ' a self ) -> postgres :: Result < Transaction < ' a > > ;
131124
132- /// Like `PostgresConnection ::batch_execute`.
133- fn batch_execute ( & self , query : & str ) -> PostgresResult < ( ) > ;
125+ /// Like `postgres::Connection ::batch_execute`.
126+ fn batch_execute ( & self , query : & str ) -> postgres :: Result < ( ) > ;
134127}
135128
136129pub struct Connection {
137- conn : Box < PostgresConnection > ,
130+ conn : Box < postgres :: Connection > ,
138131 stmts : * mut ( ) ,
139132}
140133
141134impl Drop for Connection {
142135 fn drop ( & mut self ) {
143- let _: Box < RefCell < LruCache < String , Rc < PostgresStatement < ' static > > > > > =
136+ let _: Box < RefCell < LruCache < String , Rc < postgres :: Statement < ' static > > > > > =
144137 unsafe { mem:: transmute ( self . stmts ) } ;
145138 }
146139}
147140
148141impl Connection {
149- fn get_cache < ' a > ( & ' a self ) -> & ' a RefCell < LruCache < String , Rc < PostgresStatement < ' a > > > > {
142+ fn get_cache < ' a > ( & ' a self ) -> & ' a RefCell < LruCache < String , Rc < postgres :: Statement < ' a > > > > {
150143 unsafe { mem:: transmute ( self . stmts ) }
151144 }
152145}
153146
154147impl GenericConnection for Connection {
155- fn prepare < ' a > ( & ' a self , query : & str ) -> PostgresResult < Rc < PostgresStatement < ' a > > > {
148+ fn prepare < ' a > ( & ' a self , query : & str ) -> postgres :: Result < Rc < postgres :: Statement < ' a > > > {
156149 let query = query. into_string ( ) ;
157150 let mut stmts = self . get_cache ( ) . borrow_mut ( ) ;
158151
@@ -166,29 +159,29 @@ impl GenericConnection for Connection {
166159 }
167160
168161 fn prepare_copy_in < ' a > ( & ' a self , table : & str , columns : & [ & str ] )
169- -> PostgresResult < PostgresCopyInStatement < ' a > > {
162+ -> postgres :: Result < postgres :: CopyInStatement < ' a > > {
170163 self . conn . prepare_copy_in ( table, columns)
171164 }
172165
173- fn transaction < ' a > ( & ' a self ) -> PostgresResult < Transaction < ' a > > {
166+ fn transaction < ' a > ( & ' a self ) -> postgres :: Result < Transaction < ' a > > {
174167 Ok ( Transaction {
175168 conn : self ,
176169 trans : try!( self . conn . transaction ( ) )
177170 } )
178171 }
179172
180- fn batch_execute ( & self , query : & str ) -> PostgresResult < ( ) > {
173+ fn batch_execute ( & self , query : & str ) -> postgres :: Result < ( ) > {
181174 self . conn . batch_execute ( query)
182175 }
183176}
184177
185178pub struct Transaction < ' a > {
186179 conn : & ' a Connection ,
187- trans : PostgresTransaction < ' a >
180+ trans : postgres :: Transaction < ' a >
188181}
189182
190183impl < ' a > GenericConnection for Transaction < ' a > {
191- fn prepare < ' a > ( & ' a self , query : & str ) -> PostgresResult < Rc < PostgresStatement < ' a > > > {
184+ fn prepare < ' a > ( & ' a self , query : & str ) -> postgres :: Result < Rc < postgres :: Statement < ' a > > > {
192185 let query = query. into_string ( ) ;
193186 let mut stmts = self . conn . get_cache ( ) . borrow_mut ( ) ;
194187
@@ -200,18 +193,18 @@ impl<'a> GenericConnection for Transaction<'a> {
200193 }
201194
202195 fn prepare_copy_in < ' a > ( & ' a self , table : & str , columns : & [ & str ] )
203- -> PostgresResult < PostgresCopyInStatement < ' a > > {
196+ -> postgres :: Result < postgres :: CopyInStatement < ' a > > {
204197 self . trans . prepare_copy_in ( table, columns)
205198 }
206199
207- fn transaction < ' a > ( & ' a self ) -> PostgresResult < Transaction < ' a > > {
200+ fn transaction < ' a > ( & ' a self ) -> postgres :: Result < Transaction < ' a > > {
208201 Ok ( Transaction {
209202 conn : self . conn ,
210203 trans : try!( self . trans . transaction ( ) )
211204 } )
212205 }
213206
214- fn batch_execute ( & self , query : & str ) -> PostgresResult < ( ) > {
207+ fn batch_execute ( & self , query : & str ) -> postgres :: Result < ( ) > {
215208 self . trans . batch_execute ( query)
216209 }
217210}
0 commit comments