sqlx_core/mssql/protocol/
header.rs1use crate::io::Encode;
2
3pub(crate) struct AllHeaders<'a>(pub(crate) &'a [Header]);
4
5impl Encode<'_> for AllHeaders<'_> {
6 fn encode_with(&self, buf: &mut Vec<u8>, _: ()) {
7 let offset = buf.len();
8 buf.resize(buf.len() + 4, 0);
9
10 for header in self.0 {
11 header.encode_with(buf, ());
12 }
13
14 let len = buf.len() - offset;
15 buf[offset..(offset + 4)].copy_from_slice(&(len as u32).to_le_bytes());
16 }
17}
18
19pub(crate) enum Header {
20 TransactionDescriptor {
21 outstanding_request_count: u32,
23
24 transaction_descriptor: u64,
28 },
29}
30
31impl Encode<'_> for Header {
32 fn encode_with(&self, buf: &mut Vec<u8>, _: ()) {
33 match self {
34 Header::TransactionDescriptor {
35 outstanding_request_count,
36 transaction_descriptor,
37 } => {
38 buf.extend(&18_u32.to_le_bytes()); buf.extend(&2_u16.to_le_bytes()); buf.extend(&transaction_descriptor.to_le_bytes());
41 buf.extend(&outstanding_request_count.to_le_bytes());
42 }
43 }
44 }
45}