@@ -173,50 +173,50 @@ impl Client {
173
173
///
174
174
/// Prepared statements can be executed repeatedly, and may contain query parameters (indicated by `$1`, `$2`, etc),
175
175
/// which are set when executed. Prepared statements can only be used with the connection that created them.
176
- pub fn prepare ( & mut self , query : & str ) -> impl Future < Output = Result < Statement , Error > > {
177
- self . prepare_typed ( query, & [ ] )
176
+ pub async fn prepare ( & self , query : & str ) -> Result < Statement , Error > {
177
+ self . prepare_typed ( query, & [ ] ) . await
178
178
}
179
179
180
180
/// Like `prepare`, but allows the types of query parameters to be explicitly specified.
181
181
///
182
182
/// The list of types may be smaller than the number of parameters - the types of the remaining parameters will be
183
183
/// inferred. For example, `client.prepare_typed(query, &[])` is equivalent to `client.prepare(query)`.
184
- pub fn prepare_typed (
185
- & mut self ,
184
+ pub async fn prepare_typed (
185
+ & self ,
186
186
query : & str ,
187
187
parameter_types : & [ Type ] ,
188
- ) -> impl Future < Output = Result < Statement , Error > > {
189
- prepare:: prepare ( self . inner ( ) , query, parameter_types)
188
+ ) -> Result < Statement , Error > {
189
+ prepare:: prepare ( & self . inner , query, parameter_types) . await
190
190
}
191
191
192
192
/// Executes a statement, returning a stream of the resulting rows.
193
193
///
194
194
/// # Panics
195
195
///
196
196
/// Panics if the number of parameters provided does not match the number expected.
197
- pub fn query (
198
- & mut self ,
199
- statement : & Statement ,
200
- params : & [ & ( dyn ToSql + Sync ) ] ,
201
- ) -> impl Stream < Item = Result < Row , Error > > {
197
+ pub fn query < ' a > (
198
+ & ' a self ,
199
+ statement : & ' a Statement ,
200
+ params : & ' a [ & ' a ( dyn ToSql + Sync ) ] ,
201
+ ) -> impl Stream < Item = Result < Row , Error > > + ' a {
202
202
let buf = query:: encode ( statement, params. iter ( ) . map ( |s| * s as _ ) ) ;
203
- query:: query ( self . inner ( ) , statement. clone ( ) , buf)
203
+ query:: query ( & self . inner , statement, buf)
204
204
}
205
205
206
206
/// Like [`query`], but takes an iterator of parameters rather than a slice.
207
207
///
208
208
/// [`query`]: #method.query
209
209
pub fn query_iter < ' a , I > (
210
- & mut self ,
211
- statement : & Statement ,
210
+ & ' a self ,
211
+ statement : & ' a Statement ,
212
212
params : I ,
213
- ) -> impl Stream < Item = Result < Row , Error > >
213
+ ) -> impl Stream < Item = Result < Row , Error > > + ' a
214
214
where
215
- I : IntoIterator < Item = & ' a dyn ToSql > ,
215
+ I : IntoIterator < Item = & ' a dyn ToSql > + ' a ,
216
216
I :: IntoIter : ExactSizeIterator ,
217
217
{
218
218
let buf = query:: encode ( statement, params) ;
219
- query:: query ( self . inner ( ) , statement. clone ( ) , buf)
219
+ query:: query ( & self . inner , statement, buf)
220
220
}
221
221
222
222
/// Executes a statement, returning the number of rows modified.
@@ -226,29 +226,29 @@ impl Client {
226
226
/// # Panics
227
227
///
228
228
/// Panics if the number of parameters provided does not match the number expected.
229
- pub fn execute (
230
- & mut self ,
229
+ pub async fn execute (
230
+ & self ,
231
231
statement : & Statement ,
232
232
params : & [ & ( dyn ToSql + Sync ) ] ,
233
- ) -> impl Future < Output = Result < u64 , Error > > {
233
+ ) -> Result < u64 , Error > {
234
234
let buf = query:: encode ( statement, params. iter ( ) . map ( |s| * s as _ ) ) ;
235
- query:: execute ( self . inner ( ) , buf)
235
+ query:: execute ( & self . inner , buf) . await
236
236
}
237
237
238
238
/// Like [`execute`], but takes an iterator of parameters rather than a slice.
239
239
///
240
240
/// [`execute`]: #method.execute
241
- pub fn execute_iter < ' a , I > (
242
- & mut self ,
241
+ pub async fn execute_iter < ' a , I > (
242
+ & self ,
243
243
statement : & Statement ,
244
244
params : I ,
245
- ) -> impl Future < Output = Result < u64 , Error > >
245
+ ) -> Result < u64 , Error >
246
246
where
247
247
I : IntoIterator < Item = & ' a dyn ToSql > ,
248
248
I :: IntoIter : ExactSizeIterator ,
249
249
{
250
250
let buf = query:: encode ( statement, params) ;
251
- query:: execute ( self . inner ( ) , buf)
251
+ query:: execute ( & self . inner , buf) . await
252
252
}
253
253
254
254
/// Executes a `COPY FROM STDIN` statement, returning the number of rows created.
@@ -260,7 +260,7 @@ impl Client {
260
260
///
261
261
/// Panics if the number of parameters provided does not match the number expected.
262
262
pub fn copy_in < S > (
263
- & mut self ,
263
+ & self ,
264
264
statement : & Statement ,
265
265
params : & [ & ( dyn ToSql + Sync ) ] ,
266
266
stream : S ,
@@ -281,7 +281,7 @@ impl Client {
281
281
///
282
282
/// Panics if the number of parameters provided does not match the number expected.
283
283
pub fn copy_out (
284
- & mut self ,
284
+ & self ,
285
285
statement : & Statement ,
286
286
params : & [ & ( dyn ToSql + Sync ) ] ,
287
287
) -> impl Stream < Item = Result < Bytes , Error > > {
@@ -303,7 +303,7 @@ impl Client {
303
303
/// functionality to safely embed that data in the request. Do not form statements via string concatenation and pass
304
304
/// them to this method!
305
305
pub fn simple_query (
306
- & mut self ,
306
+ & self ,
307
307
query : & str ,
308
308
) -> impl Stream < Item = Result < SimpleQueryMessage , Error > > {
309
309
simple_query:: simple_query ( self . inner ( ) , query)
@@ -319,7 +319,7 @@ impl Client {
319
319
/// Prepared statements should be use for any query which contains user-specified data, as they provided the
320
320
/// functionality to safely embed that data in the request. Do not form statements via string concatenation and pass
321
321
/// them to this method!
322
- pub fn batch_execute ( & mut self , query : & str ) -> impl Future < Output = Result < ( ) , Error > > {
322
+ pub fn batch_execute ( & self , query : & str ) -> impl Future < Output = Result < ( ) , Error > > {
323
323
simple_query:: batch_execute ( self . inner ( ) , query)
324
324
}
325
325
@@ -338,7 +338,7 @@ impl Client {
338
338
///
339
339
/// Requires the `runtime` Cargo feature (enabled by default).
340
340
#[ cfg( feature = "runtime" ) ]
341
- pub fn cancel_query < T > ( & mut self , tls : T ) -> impl Future < Output = Result < ( ) , Error > >
341
+ pub fn cancel_query < T > ( & self , tls : T ) -> impl Future < Output = Result < ( ) , Error > >
342
342
where
343
343
T : MakeTlsConnect < Socket > ,
344
344
{
@@ -354,7 +354,7 @@ impl Client {
354
354
/// Like `cancel_query`, but uses a stream which is already connected to the server rather than opening a new
355
355
/// connection itself.
356
356
pub fn cancel_query_raw < S , T > (
357
- & mut self ,
357
+ & self ,
358
358
stream : S ,
359
359
tls : T ,
360
360
) -> impl Future < Output = Result < ( ) , Error > >
0 commit comments