pub fn decode_datum(data: &mut BytesSlice<'_>) -> Result<Datum> {
    if !data.is_empty() {
        let flag = data[0];
        *data = &data[1..];
        let datum = match flag {
            INT_FLAG => number::decode_i64(data).map(Datum::I64)?,
            UINT_FLAG => number::decode_u64(data).map(Datum::U64)?,
            BYTES_FLAG => bytes::decode_bytes(data, false).map(Datum::Bytes)?,
            COMPACT_BYTES_FLAG => bytes::decode_compact_bytes(data).map(Datum::Bytes)?,
            NIL_FLAG => Datum::Null,
            FLOAT_FLAG => number::decode_f64(data).map(Datum::F64)?,
            DURATION_FLAG => {
                let nanos = number::decode_i64(data)?;
                let dur = Duration::from_nanos(nanos, MAX_FSP)?;
                Datum::Dur(dur)
            }
            DECIMAL_FLAG => data.decode_decimal().map(Datum::Dec)?,
            VAR_INT_FLAG => number::decode_var_i64(data).map(Datum::I64)?,
            VAR_UINT_FLAG => number::decode_var_u64(data).map(Datum::U64)?,
            JSON_FLAG => data.decode_json().map(Datum::Json)?,
            f => return Err(invalid_type!("unsupported data type `{}`", f)),
        };
        Ok(datum)
    } else {
        Err(Error::unexpected_eof())
    }
}
/// `decode_datum` decodes on a datum from a byte slice generated by tidb.
`decode_datum` decodes on a datum from a byte slice generated by tidb.
` decode_datum ` decodes on a datum from a byte slice generated by tidb .
pub fn decode_datum(data: &mut BytesSlice<'_>) -> Result<Datum> {
    if !data.is_empty() {
        let flag = data[0];
        *data = &data[1..];
        let datum = match flag {
            INT_FLAG => number::decode_i64(data).map(Datum::I64)?,
            UINT_FLAG => number::decode_u64(data).map(Datum::U64)?,
            BYTES_FLAG => bytes::decode_bytes(data, false).map(Datum::Bytes)?,
            COMPACT_BYTES_FLAG => bytes::decode_compact_bytes(data).map(Datum::Bytes)?,
            NIL_FLAG => Datum::Null,
            FLOAT_FLAG => number::decode_f64(data).map(Datum::F64)?,
            DURATION_FLAG => {
                let nanos = number::decode_i64(data)?;
                let dur = Duration::from_nanos(nanos, MAX_FSP)?;
                Datum::Dur(dur)
            }
            DECIMAL_FLAG => data.decode_decimal().map(Datum::Dec)?,
            VAR_INT_FLAG => number::decode_var_i64(data).map(Datum::I64)?,
            VAR_UINT_FLAG => number::decode_var_u64(data).map(Datum::U64)?,
            JSON_FLAG => data.decode_json().map(Datum::Json)?,
            f => return Err(invalid_type!("unsupported data type `{}`", f)),
        };
        Ok(datum)
    } else {
        Err(Error::unexpected_eof())
    }
}
pub fn decode_datum ( data : & mut BytesSlice < ' _ > ) -> Result < Datum > { if ! data . is_empty ( ) { let flag = data [ 0 ] ; * data = & data [ 1 .. ] ; let datum = match flag { INT_FLAG => number :: decode_i64 ( data ) . map ( Datum :: I64 ) ? , UINT_FLAG => number :: decode_u64 ( data ) . map ( Datum :: U64 ) ? , BYTES_FLAG => bytes :: decode_bytes ( data , false ) . map ( Datum :: Bytes ) ? , COMPACT_BYTES_FLAG => bytes :: decode_compact_bytes ( data ) . map ( Datum :: Bytes ) ? , NIL_FLAG => Datum :: Null , FLOAT_FLAG => number :: decode_f64 ( data ) . map ( Datum :: F64 ) ? , DURATION_FLAG => { let nanos = number :: decode_i64 ( data ) ? ; let dur = Duration :: from_nanos ( nanos , MAX_FSP ) ? ; Datum :: Dur ( dur ) } DECIMAL_FLAG => data . decode_decimal ( ) . map ( Datum :: Dec ) ? , VAR_INT_FLAG => number :: decode_var_i64 ( data ) . map ( Datum :: I64 ) ? , VAR_UINT_FLAG => number :: decode_var_u64 ( data ) . map ( Datum :: U64 ) ? , JSON_FLAG => data . decode_json ( ) . map ( Datum :: Json ) ? , f => return Err ( invalid_type ! ( " " f ) ) , } ; Ok ( datum ) } else { Err ( Error :: unexpected_eof ( ) ) } }
`decode_datum` decodes on a datum from a byte slice generated by tidb.
` decode_datum ` decodes on a datum from a byte slice generated by tidb .
data
&mut BytesSlice<'_>
data
&mut BytesSlice<'_>