pub struct PacketReader<'a> { /* private fields */ }Expand description
A reader for MySQL protocol data.
Implementations§
Source§impl<'a> PacketReader<'a>
impl<'a> PacketReader<'a>
Sourcepub fn read_u16_le(&mut self) -> Option<u16>
pub fn read_u16_le(&mut self) -> Option<u16>
Read a u16 (little-endian).
Sourcepub fn read_u24_le(&mut self) -> Option<u32>
pub fn read_u24_le(&mut self) -> Option<u32>
Read a u24 (little-endian, 3 bytes).
Sourcepub fn read_u32_le(&mut self) -> Option<u32>
pub fn read_u32_le(&mut self) -> Option<u32>
Read a u32 (little-endian).
Sourcepub fn read_u64_le(&mut self) -> Option<u64>
pub fn read_u64_le(&mut self) -> Option<u64>
Read a u64 (little-endian).
Sourcepub fn read_lenenc_int(&mut self) -> Option<u64>
pub fn read_lenenc_int(&mut self) -> Option<u64>
Read a length-encoded integer.
MySQL uses a variable-length integer encoding:
- 0x00-0xFA: 1-byte value
- 0xFC: 2-byte value follows
- 0xFD: 3-byte value follows
- 0xFE: 8-byte value follows
- 0xFB: NULL (special case for length-encoded strings)
Sourcepub fn read_lenenc_string(&mut self) -> Option<String>
pub fn read_lenenc_string(&mut self) -> Option<String>
Read a length-encoded string.
Sourcepub fn read_lenenc_bytes(&mut self) -> Option<Vec<u8>>
pub fn read_lenenc_bytes(&mut self) -> Option<Vec<u8>>
Read a length-encoded byte slice.
Sourcepub fn read_null_string(&mut self) -> Option<String>
pub fn read_null_string(&mut self) -> Option<String>
Read a null-terminated string.
Sourcepub fn read_string(&mut self, len: usize) -> Option<String>
pub fn read_string(&mut self, len: usize) -> Option<String>
Read a fixed-length string.
Sourcepub fn read_rest_string(&mut self) -> String
pub fn read_rest_string(&mut self) -> String
Read remaining data as a string.
Sourcepub fn read_bytes(&mut self, len: usize) -> Option<&'a [u8]>
pub fn read_bytes(&mut self, len: usize) -> Option<&'a [u8]>
Read a fixed number of bytes.
Sourcepub fn read_packet_header(&mut self) -> Option<PacketHeader>
pub fn read_packet_header(&mut self) -> Option<PacketHeader>
Read a packet header from raw bytes.
Sourcepub fn parse_ok_packet(&mut self) -> Option<OkPacket>
pub fn parse_ok_packet(&mut self) -> Option<OkPacket>
Parse an OK packet from the current position.
OK packet format (protocol 4.1+):
- 0x00 header (already consumed)
- affected_rows: lenenc int
- last_insert_id: lenenc int
- status_flags: 2 bytes
- warnings: 2 bytes
- info: rest of packet (optional)
Sourcepub fn parse_err_packet(&mut self) -> Option<ErrPacket>
pub fn parse_err_packet(&mut self) -> Option<ErrPacket>
Parse an Error packet from the current position.
ERR packet format (protocol 4.1+):
- 0xFF header (already consumed)
- error_code: 2 bytes
- ‘#’ marker
- sql_state: 5 bytes
- error_message: rest of packet
Sourcepub fn parse_eof_packet(&mut self) -> Option<EofPacket>
pub fn parse_eof_packet(&mut self) -> Option<EofPacket>
Parse an EOF packet from the current position.
EOF packet format:
- 0xFE header (already consumed)
- warnings: 2 bytes
- status_flags: 2 bytes
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for PacketReader<'a>
impl<'a> RefUnwindSafe for PacketReader<'a>
impl<'a> Send for PacketReader<'a>
impl<'a> Sync for PacketReader<'a>
impl<'a> Unpin for PacketReader<'a>
impl<'a> UnwindSafe for PacketReader<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).