pub struct PacketHeader {
pub packet_type: PacketType,
pub status: PacketStatus,
pub length: u16,
pub spid: u16,
pub packet_id: u8,
pub window: u8,
}Expand description
TDS packet header.
Every TDS packet begins with an 8-byte header that describes the packet type, status, and length.
Fields§
§packet_type: PacketTypeType of packet.
status: PacketStatusStatus flags.
length: u16Total packet length including header.
spid: u16Server process ID (SPID).
packet_id: u8Packet sequence number (wraps at 255).
window: u8Window (unused, should be 0).
Implementations§
Source§impl PacketHeader
impl PacketHeader
Sourcepub const fn new(
packet_type: PacketType,
status: PacketStatus,
length: u16,
) -> Self
pub const fn new( packet_type: PacketType, status: PacketStatus, length: u16, ) -> Self
Create a new packet header.
Sourcepub fn decode(src: &mut impl Buf) -> Result<Self, ProtocolError>
pub fn decode(src: &mut impl Buf) -> Result<Self, ProtocolError>
Parse a packet header from bytes.
Sourcepub fn encode_to_bytes(&self) -> Bytes
pub fn encode_to_bytes(&self) -> Bytes
Encode the packet header to a new Bytes buffer.
Sourcepub const fn payload_length(&self) -> usize
pub const fn payload_length(&self) -> usize
Get the payload length (total length minus header).
Sourcepub const fn is_end_of_message(&self) -> bool
pub const fn is_end_of_message(&self) -> bool
Check if this is the last packet in a message.
Sourcepub const fn with_packet_id(self, id: u8) -> Self
pub const fn with_packet_id(self, id: u8) -> Self
Set the packet ID (sequence number).
Trait Implementations§
Source§impl Clone for PacketHeader
impl Clone for PacketHeader
Source§fn clone(&self) -> PacketHeader
fn clone(&self) -> PacketHeader
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PacketHeader
impl Debug for PacketHeader
Source§impl Default for PacketHeader
impl Default for PacketHeader
Source§impl PartialEq for PacketHeader
impl PartialEq for PacketHeader
impl Copy for PacketHeader
impl Eq for PacketHeader
impl StructuralPartialEq for PacketHeader
Auto Trait Implementations§
impl Freeze for PacketHeader
impl RefUnwindSafe for PacketHeader
impl Send for PacketHeader
impl Sync for PacketHeader
impl Unpin for PacketHeader
impl UnwindSafe for PacketHeader
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