pub fn parse(key: &[u8]) -> (KeyPrefix, &[u8]) {
        if key.is_empty() {
            return (KeyPrefix::Unknown, key);
        }

        match key[0] {
            RAW_KEY_PREFIX => {
                let mut slice = &key[1..];
                match slice.read_var_u64() {
                    Ok(keyspace_id) => (KeyPrefix::Raw { keyspace_id }, slice),
                    Err(_) => (KeyPrefix::Unknown, key),
                }
            }
            TXN_KEY_PREFIX => {
                let mut slice = &key[1..];
                match slice.read_var_u64() {
                    Ok(keyspace_id) => (KeyPrefix::Txn { keyspace_id }, slice),
                    Err(_) => (KeyPrefix::Unknown, key),
                }
            }
            b'm' | b't' => {
                // TiDB prefix is also a part of the user key, so don't strip the prefix.
                (KeyPrefix::TiDB, key)
            }
            _ => (KeyPrefix::Unknown, key),
        }
    }
/// Parse the keys prefix according to the API V2 definition and return the user key.
Parse the keys prefix according to the API V2 definition and return the user key.
Parse the keys prefix according to the API V2 definition and return the user key .
pub fn parse(key: &[u8]) -> (KeyPrefix, &[u8]) {
        if key.is_empty() {
            return (KeyPrefix::Unknown, key);
        }
        match key[0] {
            RAW_KEY_PREFIX => {
                let mut slice = &key[1..];
                match slice.read_var_u64() {
                    Ok(keyspace_id) => (KeyPrefix::Raw { keyspace_id }, slice),
                    Err(_) => (KeyPrefix::Unknown, key),
                }
            }
            TXN_KEY_PREFIX => {
                let mut slice = &key[1..];
                match slice.read_var_u64() {
                    Ok(keyspace_id) => (KeyPrefix::Txn { keyspace_id }, slice),
                    Err(_) => (KeyPrefix::Unknown, key),
                }
            }
            b'm' | b't' => {
                // TiDB prefix is also a part of the user key, so don't strip the prefix.
                (KeyPrefix::TiDB, key)
            }
            _ => (KeyPrefix::Unknown, key),
        }
    }
pub fn parse ( key : & [ u8 ] ) -> ( KeyPrefix , & [ u8 ] ) { if key . is_empty ( ) { return ( KeyPrefix :: Unknown , key ) ; } match key [ 0 ] { RAW_KEY_PREFIX => { let mut slice = & key [ 1 .. ] ; match slice . read_var_u64 ( ) { Ok ( keyspace_id ) => ( KeyPrefix :: Raw { keyspace_id } , slice ) , Err ( _ ) => ( KeyPrefix :: Unknown , key ) , } } TXN_KEY_PREFIX => { let mut slice = & key [ 1 .. ] ; match slice . read_var_u64 ( ) { Ok ( keyspace_id ) => ( KeyPrefix :: Txn { keyspace_id } , slice ) , Err ( _ ) => ( KeyPrefix :: Unknown , key ) , } } b'm' | b't' => { // TiDB prefix is also a part of the user key, so don't strip the prefix. ( KeyPrefix :: TiDB , key ) } _ => ( KeyPrefix :: Unknown , key ) , } }
Parse the keys prefix according to the API V2 definition and return the user key.
Parse the keys prefix according to the API V2 definition and return the user key .
key
&[u8]