1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use crate::io::Encode;
use crate::postgres::io::PgBufMutExt;
use crate::postgres::PgValueFormat;
#[derive(Debug)]
pub struct Bind<'a> {
pub portal: Option<u32>,
pub statement: u32,
pub formats: &'a [PgValueFormat],
pub num_params: i16,
pub params: &'a [u8],
pub result_formats: &'a [PgValueFormat],
}
impl Encode<'_> for Bind<'_> {
fn encode_with(&self, buf: &mut Vec<u8>, _: ()) {
buf.push(b'B');
buf.put_length_prefixed(|buf| {
buf.put_portal_name(self.portal);
buf.put_statement_name(self.statement);
buf.extend(&(self.formats.len() as i16).to_be_bytes());
for &format in self.formats {
buf.extend(&(format as i16).to_be_bytes());
}
buf.extend(&self.num_params.to_be_bytes());
buf.extend(self.params);
buf.extend(&(self.result_formats.len() as i16).to_be_bytes());
for &format in self.result_formats {
buf.extend(&(format as i16).to_be_bytes());
}
});
}
}