File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -4,29 +4,32 @@ use async_trait::async_trait;
44use postgres:: Error ;
55use tokio_postgres as postgres;
66
7- pub struct Client ( u64 , postgres:: Client ) ;
7+ pub struct Client {
8+ index : u64 ,
9+ client : postgres:: Client ,
10+ }
811
912impl Client {
1013 pub async fn new ( client : postgres:: Client ) -> Result < Client , Error > {
1114 let index = client. query ( "SELECT * FROM Links;" , & [ ] ) . await ?. len ( ) as u64 ;
12- Ok ( Self ( index, client) )
15+ Ok ( Self { index, client } )
1316 }
1417
1518 pub async fn transaction ( & mut self ) -> Result < Transaction < ' _ > , Error > {
16- let transaction = self . 1 . transaction ( ) . await . unwrap ( ) ;
17- Ok ( Transaction :: new ( transaction, self . 0 ) )
19+ let transaction = self . client . transaction ( ) . await . unwrap ( ) ;
20+ Ok ( Transaction :: new ( transaction, self . index ) )
1821 }
1922}
2023
2124#[ async_trait]
2225impl Cruds < ' _ , postgres:: Client > for Client {
2326 #[ inline]
2427 fn index ( & mut self ) -> & mut u64 {
25- & mut self . 0
28+ & mut self . index
2629 }
2730
2831 #[ inline]
2932 fn executor ( & mut self ) -> & postgres:: Client {
30- & self . 1
33+ & self . client
3134 }
3235}
You can’t perform that action at this time.
0 commit comments