File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
sqlx-postgres/src/connection Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ pub use self::stream::PgStream;
27
27
pub ( crate ) mod describe;
28
28
mod establish;
29
29
mod executor;
30
+ mod request;
30
31
mod sasl;
31
32
mod stream;
32
33
mod tls;
Original file line number Diff line number Diff line change
1
+ use futures_channel:: mpsc:: UnboundedSender ;
2
+ use sqlx_core:: { io:: ProtocolEncode , Error } ;
3
+
4
+ use crate :: message:: { self , EncodeMessage , FrontendMessage , ReceivedMessage } ;
5
+
6
+ /// A request for the background worker.
7
+ #[ derive( Debug ) ]
8
+ pub struct IoRequest {
9
+ pub chan : Option < UnboundedSender < ReceivedMessage > > ,
10
+ pub data : Vec < u8 > ,
11
+ }
12
+
13
+ pub struct MessageBuf {
14
+ data : Vec < u8 > ,
15
+ }
16
+
17
+ impl MessageBuf {
18
+ pub fn new ( ) -> Self {
19
+ Self { data : Vec :: new ( ) }
20
+ }
21
+
22
+ #[ inline( always) ]
23
+ pub fn write < ' en , T > ( & mut self , value : T ) -> sqlx_core:: Result < ( ) >
24
+ where
25
+ T : ProtocolEncode < ' en , ( ) > ,
26
+ {
27
+ value. encode ( & mut self . data )
28
+ }
29
+
30
+ #[ inline( always) ]
31
+ pub fn write_sync ( & mut self ) {
32
+ self . write_msg ( message:: Sync )
33
+ . expect ( "BUG: Sync should not be too big for protocol" ) ;
34
+ }
35
+
36
+ #[ inline( always) ]
37
+ pub ( crate ) fn write_msg ( & mut self , message : impl FrontendMessage ) -> Result < ( ) , Error > {
38
+ self . write ( EncodeMessage ( message) )
39
+ }
40
+
41
+ pub ( crate ) fn buf_mut ( & mut self ) -> & mut Vec < u8 > {
42
+ & mut self . data
43
+ }
44
+
45
+ pub fn finish ( self ) -> IoRequest {
46
+ IoRequest {
47
+ data : self . data ,
48
+ chan : None ,
49
+ }
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments