@@ -4,6 +4,7 @@ use std::str::FromStr;
44
55use bb8:: { CustomizeConnection , Pool } ;
66use bb8_postgres:: PostgresConnectionManager ;
7+ use futures_util:: future:: BoxFuture ;
78use tokio_postgres:: config:: Config ;
89use tokio_postgres:: tls:: { MakeTlsConnect , TlsConnect } ;
910use tokio_postgres:: { Client , Error , Socket , Statement } ;
@@ -43,14 +44,23 @@ async fn main() {
4344struct Customizer ;
4445
4546impl CustomizeConnection < CustomPostgresConnection , Error > for Customizer {
46- async fn on_acquire ( & self , conn : & mut CustomPostgresConnection ) -> Result < ( ) , Error > {
47- conn. custom_state
48- . insert ( QueryName :: BasicSelect , conn. prepare ( "SELECT 1" ) . await ?) ;
49-
50- conn. custom_state
51- . insert ( QueryName :: Addition , conn. prepare ( "SELECT 1 + 1 + 1" ) . await ?) ;
52-
53- Ok ( ( ) )
47+ fn on_acquire < ' a , ' b , ' r > (
48+ & ' a self ,
49+ conn : & ' b mut CustomPostgresConnection ,
50+ ) -> BoxFuture < ' r , Result < ( ) , Error > >
51+ where
52+ ' a : ' r ,
53+ ' b : ' r ,
54+ {
55+ Box :: pin ( async {
56+ conn. custom_state
57+ . insert ( QueryName :: BasicSelect , conn. prepare ( "SELECT 1" ) . await ?) ;
58+
59+ conn. custom_state
60+ . insert ( QueryName :: Addition , conn. prepare ( "SELECT 1 + 1 + 1" ) . await ?) ;
61+
62+ Ok ( ( ) )
63+ } )
5464 }
5565}
5666
0 commit comments