/// Reads mysql packet payload returns it with new seq_id value.
Reads mysql packet payload returns it with new seq_id value.
Reads mysql packet payload returns it with new seq_id value .
fn read_packet(&mut self, mut seq_id: u8) -> MyResult<(Vec<u8>, u8)> {
        let mut output = Vec::new();
        let mut pos = 0;
        loop {
            let payload_len = try!(self.read_le_uint_n(3)) as usize;
            let srv_seq_id = try!(self.read_u8());
            if srv_seq_id != seq_id {
                return Err(MyDriverError(PacketOutOfSync));
            }
            seq_id += 1;
            if payload_len == consts::MAX_PAYLOAD_LEN {
                output.reserve(pos + consts::MAX_PAYLOAD_LEN);
                unsafe { output.set_len(pos + consts::MAX_PAYLOAD_LEN); }
                try!(self.read_at_least(consts::MAX_PAYLOAD_LEN,
                                        &mut output[pos..]));
                pos += consts::MAX_PAYLOAD_LEN;
            } else if payload_len == 0 {
                break;
            } else {
                output.reserve(pos + payload_len);
                unsafe { output.set_len(pos + payload_len); }
                try!(self.read_at_least(payload_len,
                                        &mut output[pos..]));
                break;
            }
        }
        Ok((output, seq_id))
    }
fn read_packet ( & mut self , mut seq_id : u8 ) -> MyResult < ( Vec < u8 > , u8 ) > { let mut output = Vec :: new ( ) ; let mut pos = 0 ; loop { let payload_len = try ! ( self read_le_uint_n ( 3 ) ) as usize ; let srv_seq_id = try ! ( self read_u8 ( ) ) ; if srv_seq_id != seq_id { return Err ( MyDriverError ( PacketOutOfSync ) ) ; } seq_id += 1 ; if payload_len == consts :: MAX_PAYLOAD_LEN { output . reserve ( pos + consts :: MAX_PAYLOAD_LEN ) ; unsafe { output . set_len ( pos + consts :: MAX_PAYLOAD_LEN ) ; } try ! ( self read_at_least ( consts MAX_PAYLOAD_LEN mut output [ pos ] ) ) ; pos += consts :: MAX_PAYLOAD_LEN ; } else if payload_len == 0 { break ; } else { output . reserve ( pos + payload_len ) ; unsafe { output . set_len ( pos + payload_len ) ; } try ! ( self read_at_least ( payload_len mut output [ pos ] ) ) ; break ; } } Ok ( ( output , seq_id ) ) }
Reads mysql packet payload returns it with new seq_id value.
Reads mysql packet payload returns it with new seq_id value .
&mut self
seq_id
u8