pub(crate) fn read_variable_length_integer<R: Read>(r: &mut R) -> io::Result<i64> {
    let first = r.read_u8()?;
    if first < 0xfb {
        Ok(i64::from(first as i8))
    } else if first == 0xfc {
        Ok(i64::from(r.read_i16::<LittleEndian>()?))
    } else if first == 0xfd {
        // why are there three byte integers fucking mysql
        let mut buf = [0u8; 4];
        r.read_exact(&mut buf[0..3])?;
        // TODO: sign-extend to fill that top byte
        Ok(i64::from(LittleEndian::read_i32(&buf)))
    } else if first == 0xfe {
        r.read_i64::<LittleEndian>()
    } else {
        unreachable!();
    }
}
// This module contains miscellaneous shitty functions for reading various
// MySQL data types out of a packet (or, well, a Read).
//
// It's all garbage all the way down.
This module contains miscellaneous shitty functions for reading various
MySQL data types out of a packet (or, well, a Read).

It's all garbage all the way down.
This module contains miscellaneous shitty functions for reading various MySQL data types out of a packet ( or well a Read ) . It ' s all garbage all the way down .
pub(crate) fn read_variable_length_integer<R: Read>(r: &mut R) -> io::Result<i64> {
    let first = r.read_u8()?;
    if first < 0xfb {
        Ok(i64::from(first as i8))
    } else if first == 0xfc {
        Ok(i64::from(r.read_i16::<LittleEndian>()?))
    } else if first == 0xfd {
        // why are there three byte integers fucking mysql
        let mut buf = [0u8; 4];
        r.read_exact(&mut buf[0..3])?;
        // TODO: sign-extend to fill that top byte
        Ok(i64::from(LittleEndian::read_i32(&buf)))
    } else if first == 0xfe {
        r.read_i64::<LittleEndian>()
    } else {
        unreachable!();
    }
}
pub ( crate ) fn read_variable_length_integer < R : Read > ( r : & mut R ) -> io :: Result < i64 > { let first = r . read_u8 ( ) ? ; if first < 0xfb { Ok ( i64 :: from ( first as i8 ) ) } else if first == 0xfc { Ok ( i64 :: from ( r . read_i16 :: < LittleEndian > ( ) ? ) ) } else if first == 0xfd { // why are there three byte integers fucking mysql let mut buf = [ 0u8 ; 4 ] ; r . read_exact ( & mut buf [ 0 .. 3 ] ) ? ; // TODO: sign-extend to fill that top byte Ok ( i64 :: from ( LittleEndian :: read_i32 ( & buf ) ) ) } else if first == 0xfe { r . read_i64 :: < LittleEndian > ( ) } else { unreachable ! ( ) ; } }
This module contains miscellaneous shitty functions for reading various
MySQL data types out of a packet (or, well, a Read).
This module contains miscellaneous shitty functions for reading various MySQL data types out of a packet ( or well a Read ) .
r
&mut R