@@ -12,9 +12,6 @@ mod private {
1212/// This trait is "sealed", and cannot be implemented outside of this crate.
1313#[ async_trait]
1414pub trait GenericClient : private:: Sealed {
15- /// Get a reference to the underlying `Client`
16- fn client ( & self ) -> & Client ;
17-
1815 /// Like `Client::execute`.
1916 async fn execute < T > ( & self , query : & T , params : & [ & ( dyn ToSql + Sync ) ] ) -> Result < u64 , Error >
2017 where
@@ -71,16 +68,15 @@ pub trait GenericClient: private::Sealed {
7168
7269 /// Like `Client::transaction`.
7370 async fn transaction ( & mut self ) -> Result < Transaction < ' _ > , Error > ;
71+
72+ /// Returns a reference to the underlying `Client`.
73+ fn client ( & self ) -> & Client ;
7474}
7575
7676impl private:: Sealed for Client { }
7777
7878#[ async_trait]
7979impl GenericClient for Client {
80- fn client ( & self ) -> & Client {
81- self
82- }
83-
8480 async fn execute < T > ( & self , query : & T , params : & [ & ( dyn ToSql + Sync ) ] ) -> Result < u64 , Error >
8581 where
8682 T : ?Sized + ToStatement + Sync + Send ,
@@ -152,17 +148,17 @@ impl GenericClient for Client {
152148 async fn transaction ( & mut self ) -> Result < Transaction < ' _ > , Error > {
153149 self . transaction ( ) . await
154150 }
151+
152+ fn client ( & self ) -> & Client {
153+ self
154+ }
155155}
156156
157157impl private:: Sealed for Transaction < ' _ > { }
158158
159159#[ async_trait]
160160#[ allow( clippy:: needless_lifetimes) ]
161161impl GenericClient for Transaction < ' _ > {
162- fn client ( & self ) -> & Client {
163- self . client ( )
164- }
165-
166162 async fn execute < T > ( & self , query : & T , params : & [ & ( dyn ToSql + Sync ) ] ) -> Result < u64 , Error >
167163 where
168164 T : ?Sized + ToStatement + Sync + Send ,
@@ -235,4 +231,8 @@ impl GenericClient for Transaction<'_> {
235231 async fn transaction < ' a > ( & ' a mut self ) -> Result < Transaction < ' a > , Error > {
236232 self . transaction ( ) . await
237233 }
234+
235+ fn client ( & self ) -> & Client {
236+ self . client ( )
237+ }
238238}
0 commit comments