Debian Codegraph @

src/protocol/response/eof.rs

raw symbols SCIP
1 use bytes::{Buf, Bytes};
2
3 use crate::error::Error;
4 use crate::io::ProtocolDecode;
5 use crate::protocol::response::Status;
6 use crate::protocol::Capabilities;
7
8 /// Marks the end of a result set, returning status and warnings.
9 ///
10 /// # Note
11 ///
12 /// The EOF packet is deprecated as of MySQL 5.7.5. SQLx only uses this packet for MySQL
13 /// prior MySQL versions.
14 #[derive(Debug)]
15 pub struct EofPacket {
16 #[allow(dead_code)]
17 pub warnings: u16,
18 pub status: Status,
19 }
20
21 impl ProtocolDecode<'_, Capabilities> for EofPacket {
22 fn decode_with(mut buf: Bytes, _: Capabilities) -> Result<Self, Error> {
23 let header = buf.get_u8();
24 if header != 0xfe {
25 return Err(err_protocol!(
26 "expected 0xfe (EOF_Packet) but found 0x{:x}",
27 header
28 ));
29 }
30
31 let warnings = buf.get_u16_le();
32 let status = Status::from_bits_truncate(buf.get_u16_le());
33
34 Ok(Self { status, warnings })
35 }
36 }