pub(crate) fn write(&mut self, packet: impl Encode) {
        let buf = self.stream.buffer_mut();

        // Allocate room for the header that we write after the packet;
        // so, we can get an accurate and cheap measure of packet length

        let header_offset = buf.len();
        buf.advance(4);

        packet.encode(buf, self.capabilities);

        // Determine length of encoded packet
        // and write to allocated header

        let len = buf.len() - header_offset - 4;
        let mut header = &mut buf[header_offset..];

        LittleEndian::write_u32(&mut header, len as u32); // len

        // Take the last sequence number received, if any, and increment by 1
        // If there was no sequence number, we only increment if we split packets
        header[3] = self.next_seq_no;
        self.next_seq_no = self.next_seq_no.wrapping_add(1);
    }
/// Write the packet to the stream ( do not send to the server )
Write the packet to the stream ( do not send to the server )
Write the packet to the stream ( do not send to the server )
pub(crate) fn write(&mut self, packet: impl Encode) {
        let buf = self.stream.buffer_mut();
        // Allocate room for the header that we write after the packet;
        // so, we can get an accurate and cheap measure of packet length
        let header_offset = buf.len();
        buf.advance(4);
        packet.encode(buf, self.capabilities);
        // Determine length of encoded packet
        // and write to allocated header
        let len = buf.len() - header_offset - 4;
        let mut header = &mut buf[header_offset..];
        LittleEndian::write_u32(&mut header, len as u32); // len
        // Take the last sequence number received, if any, and increment by 1
        // If there was no sequence number, we only increment if we split packets
        header[3] = self.next_seq_no;
        self.next_seq_no = self.next_seq_no.wrapping_add(1);
    }
pub ( crate ) fn write ( & mut self , packet : impl Encode ) { let buf = self . stream . buffer_mut ( ) ; // Allocate room for the header that we write after the packet; // so, we can get an accurate and cheap measure of packet length let header_offset = buf . len ( ) ; buf . advance ( 4 ) ; packet . encode ( buf , self . capabilities ) ; // Determine length of encoded packet // and write to allocated header let len = buf . len ( ) - header_offset - 4 ; let mut header = & mut buf [ header_offset .. ] ; LittleEndian :: write_u32 ( & mut header , len as u32 ) ; // len // Take the last sequence number received, if any, and increment by 1 // If there was no sequence number, we only increment if we split packets header [ 3 ] = self . next_seq_no ; self . next_seq_no = self . next_seq_no . wrapping_add ( 1 ) ; }
Write the packet to the stream ( do not send to the server )
Write the packet to the stream ( do not send to the server )
&mut self
packet
impl Encode
&mut self
packet
impl Encode