pub fn split_datum(buf: &[u8], desc: bool) -> Result<(&[u8], &[u8])> {
    if buf.is_empty() {
        return Err(box_err!("{} is too short", escape(buf)));
    }
    let pos = match buf[0] {
        INT_FLAG => number::I64_SIZE,
        UINT_FLAG => number::U64_SIZE,
        BYTES_FLAG => bytes::encoded_bytes_len(&buf[1..], desc),
        COMPACT_BYTES_FLAG => bytes::encoded_compact_len(&buf[1..]),
        NIL_FLAG => 0,
        FLOAT_FLAG => number::F64_SIZE,
        DURATION_FLAG => number::I64_SIZE,
        DECIMAL_FLAG => mysql::dec_encoded_len(&buf[1..])?,
        VAR_INT_FLAG => {
            let mut v = &buf[1..];
            let l = v.len();
            number::decode_var_i64(&mut v)?;
            l - v.len()
        }
        VAR_UINT_FLAG => {
            let mut v = &buf[1..];
            let l = v.len();
            number::decode_var_u64(&mut v)?;
            l - v.len()
        }
        JSON_FLAG => {
            let mut v = &buf[1..];
            let l = v.len();
            v.decode_json()?;
            l - v.len()
        }
        f => return Err(invalid_type!("unsupported data type `{}`", f)),
    };
    if buf.len() < pos + 1 {
        return Err(box_err!("{} is too short", escape(buf)));
    }
    Ok(buf.split_at(1 + pos))
}
/// Split bytes array into two part: first one is a whole datum's encoded data,
/// and the second part is the remaining data.
Split bytes array into two part: first one is a whole datum's encoded data,
and the second part is the remaining data.
Split bytes array into two part : first one is a whole datum ' s encoded data and the second part is the remaining data .
pub fn split_datum(buf: &[u8], desc: bool) -> Result<(&[u8], &[u8])> {
    if buf.is_empty() {
        return Err(box_err!("{} is too short", escape(buf)));
    }
    let pos = match buf[0] {
        INT_FLAG => number::I64_SIZE,
        UINT_FLAG => number::U64_SIZE,
        BYTES_FLAG => bytes::encoded_bytes_len(&buf[1..], desc),
        COMPACT_BYTES_FLAG => bytes::encoded_compact_len(&buf[1..]),
        NIL_FLAG => 0,
        FLOAT_FLAG => number::F64_SIZE,
        DURATION_FLAG => number::I64_SIZE,
        DECIMAL_FLAG => mysql::dec_encoded_len(&buf[1..])?,
        VAR_INT_FLAG => {
            let mut v = &buf[1..];
            let l = v.len();
            number::decode_var_i64(&mut v)?;
            l - v.len()
        }
        VAR_UINT_FLAG => {
            let mut v = &buf[1..];
            let l = v.len();
            number::decode_var_u64(&mut v)?;
            l - v.len()
        }
        JSON_FLAG => {
            let mut v = &buf[1..];
            let l = v.len();
            v.decode_json()?;
            l - v.len()
        }
        f => return Err(invalid_type!("unsupported data type `{}`", f)),
    };
    if buf.len() < pos + 1 {
        return Err(box_err!("{} is too short", escape(buf)));
    }
    Ok(buf.split_at(1 + pos))
}
pub fn split_datum ( buf : & [ u8 ] , desc : bool ) -> Result < ( & [ u8 ] , & [ u8 ] ) > { if buf . is_empty ( ) { return Err ( box_err ! ( " " escape ( buf ) ) ) ; } let pos = match buf [ 0 ] { INT_FLAG => number :: I64_SIZE , UINT_FLAG => number :: U64_SIZE , BYTES_FLAG => bytes :: encoded_bytes_len ( & buf [ 1 .. ] , desc ) , COMPACT_BYTES_FLAG => bytes :: encoded_compact_len ( & buf [ 1 .. ] ) , NIL_FLAG => 0 , FLOAT_FLAG => number :: F64_SIZE , DURATION_FLAG => number :: I64_SIZE , DECIMAL_FLAG => mysql :: dec_encoded_len ( & buf [ 1 .. ] ) ? , VAR_INT_FLAG => { let mut v = & buf [ 1 .. ] ; let l = v . len ( ) ; number :: decode_var_i64 ( & mut v ) ? ; l - v . len ( ) } VAR_UINT_FLAG => { let mut v = & buf [ 1 .. ] ; let l = v . len ( ) ; number :: decode_var_u64 ( & mut v ) ? ; l - v . len ( ) } JSON_FLAG => { let mut v = & buf [ 1 .. ] ; let l = v . len ( ) ; v . decode_json ( ) ? ; l - v . len ( ) } f => return Err ( invalid_type ! ( " " f ) ) , } ; if buf . len ( ) < pos + 1 { return Err ( box_err ! ( " " escape ( buf ) ) ) ; } Ok ( buf . split_at ( 1 + pos ) ) }
Split bytes array into two part: first one is a whole datum's encoded data,
and the second part is the remaining data.
Split bytes array into two part : first one is a whole datum ' s encoded data and the second part is the remaining data .
buf
&[u8]
desc
bool
buf
&[u8]
desc
bool