1
1
use crate :: query:: RowStream ;
2
2
use crate :: types:: { BorrowToSql , ToSql , Type } ;
3
- use crate :: { Client , Error , Row , Statement , ToStatement , Transaction } ;
3
+ use crate :: { Client , Error , Row , SimpleQueryMessage , Statement , ToStatement , Transaction } ;
4
4
use async_trait:: async_trait;
5
5
6
6
mod private {
@@ -12,25 +12,25 @@ mod private {
12
12
/// This trait is "sealed", and cannot be implemented outside of this crate.
13
13
#[ async_trait]
14
14
pub trait GenericClient : private:: Sealed {
15
- /// Like `Client::execute`.
15
+ /// Like [ `Client::execute`] .
16
16
async fn execute < T > ( & self , query : & T , params : & [ & ( dyn ToSql + Sync ) ] ) -> Result < u64 , Error >
17
17
where
18
18
T : ?Sized + ToStatement + Sync + Send ;
19
19
20
- /// Like `Client::execute_raw`.
20
+ /// Like [ `Client::execute_raw`] .
21
21
async fn execute_raw < P , I , T > ( & self , statement : & T , params : I ) -> Result < u64 , Error >
22
22
where
23
23
T : ?Sized + ToStatement + Sync + Send ,
24
24
P : BorrowToSql ,
25
25
I : IntoIterator < Item = P > + Sync + Send ,
26
26
I :: IntoIter : ExactSizeIterator ;
27
27
28
- /// Like `Client::query`.
28
+ /// Like [ `Client::query`] .
29
29
async fn query < T > ( & self , query : & T , params : & [ & ( dyn ToSql + Sync ) ] ) -> Result < Vec < Row > , Error >
30
30
where
31
31
T : ?Sized + ToStatement + Sync + Send ;
32
32
33
- /// Like `Client::query_one`.
33
+ /// Like [ `Client::query_one`] .
34
34
async fn query_one < T > (
35
35
& self ,
36
36
statement : & T ,
@@ -39,7 +39,7 @@ pub trait GenericClient: private::Sealed {
39
39
where
40
40
T : ?Sized + ToStatement + Sync + Send ;
41
41
42
- /// Like `Client::query_opt`.
42
+ /// Like [ `Client::query_opt`] .
43
43
async fn query_opt < T > (
44
44
& self ,
45
45
statement : & T ,
@@ -48,31 +48,34 @@ pub trait GenericClient: private::Sealed {
48
48
where
49
49
T : ?Sized + ToStatement + Sync + Send ;
50
50
51
- /// Like `Client::query_raw`.
51
+ /// Like [ `Client::query_raw`] .
52
52
async fn query_raw < T , P , I > ( & self , statement : & T , params : I ) -> Result < RowStream , Error >
53
53
where
54
54
T : ?Sized + ToStatement + Sync + Send ,
55
55
P : BorrowToSql ,
56
56
I : IntoIterator < Item = P > + Sync + Send ,
57
57
I :: IntoIter : ExactSizeIterator ;
58
58
59
- /// Like `Client::prepare`.
59
+ /// Like [ `Client::prepare`] .
60
60
async fn prepare ( & self , query : & str ) -> Result < Statement , Error > ;
61
61
62
- /// Like `Client::prepare_typed`.
62
+ /// Like [ `Client::prepare_typed`] .
63
63
async fn prepare_typed (
64
64
& self ,
65
65
query : & str ,
66
66
parameter_types : & [ Type ] ,
67
67
) -> Result < Statement , Error > ;
68
68
69
- /// Like `Client::transaction`.
69
+ /// Like [ `Client::transaction`] .
70
70
async fn transaction ( & mut self ) -> Result < Transaction < ' _ > , Error > ;
71
71
72
- /// Like `Client::batch_execute`.
72
+ /// Like [ `Client::batch_execute`] .
73
73
async fn batch_execute ( & self , query : & str ) -> Result < ( ) , Error > ;
74
74
75
- /// Returns a reference to the underlying `Client`.
75
+ /// Like [`Client::simple_query`].
76
+ async fn simple_query ( & self , query : & str ) -> Result < Vec < SimpleQueryMessage > , Error > ;
77
+
78
+ /// Returns a reference to the underlying [`Client`].
76
79
fn client ( & self ) -> & Client ;
77
80
}
78
81
@@ -156,6 +159,10 @@ impl GenericClient for Client {
156
159
self . batch_execute ( query) . await
157
160
}
158
161
162
+ async fn simple_query ( & self , query : & str ) -> Result < Vec < SimpleQueryMessage > , Error > {
163
+ self . simple_query ( query) . await
164
+ }
165
+
159
166
fn client ( & self ) -> & Client {
160
167
self
161
168
}
@@ -243,6 +250,10 @@ impl GenericClient for Transaction<'_> {
243
250
self . batch_execute ( query) . await
244
251
}
245
252
253
+ async fn simple_query ( & self , query : & str ) -> Result < Vec < SimpleQueryMessage > , Error > {
254
+ self . simple_query ( query) . await
255
+ }
256
+
246
257
fn client ( & self ) -> & Client {
247
258
self . client ( )
248
259
}
0 commit comments