@@ -125,12 +125,8 @@ pub trait SimpleAsyncConnection {
125
125
fn batch_execute ( & mut self , query : & str ) -> impl Future < Output = QueryResult < ( ) > > + Send ;
126
126
}
127
127
128
- /// An async connection to a database
129
- ///
130
- /// This trait represents a n async database connection. It can be used to query the database through
131
- /// the query dsl provided by diesel, custom extensions or raw sql queries. It essentially mirrors
132
- /// the sync diesel [`Connection`](diesel::connection::Connection) implementation
133
- pub trait AsyncConnection : SimpleAsyncConnection + Sized + Send {
128
+ /// Core trait for an async database connection
129
+ pub trait AsyncConnectionCore : SimpleAsyncConnection + Send {
134
130
/// The future returned by `AsyncConnection::execute`
135
131
type ExecuteFuture < ' conn , ' query > : Future < Output = QueryResult < usize > > + Send ;
136
132
/// The future returned by `AsyncConnection::load`
@@ -143,6 +139,37 @@ pub trait AsyncConnection: SimpleAsyncConnection + Sized + Send {
143
139
/// The backend this type connects to
144
140
type Backend : Backend ;
145
141
142
+ #[ doc( hidden) ]
143
+ fn load < ' conn , ' query , T > ( & ' conn mut self , source : T ) -> Self :: LoadFuture < ' conn , ' query >
144
+ where
145
+ T : AsQuery + ' query ,
146
+ T :: Query : QueryFragment < Self :: Backend > + QueryId + ' query ;
147
+
148
+ #[ doc( hidden) ]
149
+ fn execute_returning_count < ' conn , ' query , T > (
150
+ & ' conn mut self ,
151
+ source : T ,
152
+ ) -> Self :: ExecuteFuture < ' conn , ' query >
153
+ where
154
+ T : QueryFragment < Self :: Backend > + QueryId + ' query ;
155
+
156
+ // These functions allow the associated types (`ExecuteFuture`, `LoadFuture`, etc.) to
157
+ // compile without a `where Self: '_` clause. This is needed the because bound causes
158
+ // lifetime issues when using `transaction()` with generic `AsyncConnection`s.
159
+ //
160
+ // See: https://github.com/rust-lang/rust/issues/87479
161
+ #[ doc( hidden) ]
162
+ fn _silence_lint_on_execute_future ( _: Self :: ExecuteFuture < ' _ , ' _ > ) { }
163
+ #[ doc( hidden) ]
164
+ fn _silence_lint_on_load_future ( _: Self :: LoadFuture < ' _ , ' _ > ) { }
165
+ }
166
+
167
+ /// An async connection to a database
168
+ ///
169
+ /// This trait represents an async database connection. It can be used to query the database through
170
+ /// the query dsl provided by diesel, custom extensions or raw sql queries. It essentially mirrors
171
+ /// the sync diesel [`Connection`](diesel::connection::Connection) implementation
172
+ pub trait AsyncConnection : AsyncConnectionCore + Sized {
146
173
#[ doc( hidden) ]
147
174
type TransactionManager : TransactionManager < Self > ;
148
175
@@ -336,35 +363,11 @@ pub trait AsyncConnection: SimpleAsyncConnection + Sized + Send {
336
363
} )
337
364
}
338
365
339
- #[ doc( hidden) ]
340
- fn load < ' conn , ' query , T > ( & ' conn mut self , source : T ) -> Self :: LoadFuture < ' conn , ' query >
341
- where
342
- T : AsQuery + ' query ,
343
- T :: Query : QueryFragment < Self :: Backend > + QueryId + ' query ;
344
-
345
- #[ doc( hidden) ]
346
- fn execute_returning_count < ' conn , ' query , T > (
347
- & ' conn mut self ,
348
- source : T ,
349
- ) -> Self :: ExecuteFuture < ' conn , ' query >
350
- where
351
- T : QueryFragment < Self :: Backend > + QueryId + ' query ;
352
-
353
366
#[ doc( hidden) ]
354
367
fn transaction_state (
355
368
& mut self ,
356
369
) -> & mut <Self :: TransactionManager as TransactionManager < Self > >:: TransactionStateData ;
357
370
358
- // These functions allow the associated types (`ExecuteFuture`, `LoadFuture`, etc.) to
359
- // compile without a `where Self: '_` clause. This is needed the because bound causes
360
- // lifetime issues when using `transaction()` with generic `AsyncConnection`s.
361
- //
362
- // See: https://github.com/rust-lang/rust/issues/87479
363
- #[ doc( hidden) ]
364
- fn _silence_lint_on_execute_future ( _: Self :: ExecuteFuture < ' _ , ' _ > ) { }
365
- #[ doc( hidden) ]
366
- fn _silence_lint_on_load_future ( _: Self :: LoadFuture < ' _ , ' _ > ) { }
367
-
368
371
#[ doc( hidden) ]
369
372
fn instrumentation ( & mut self ) -> & mut dyn Instrumentation ;
370
373
0 commit comments