1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
use std::io::Error as IoError; use constants::encoding_type; #[derive(Debug,Clone)] pub enum ZiplistEntry { String(Vec<u8>), Number(i64), } pub type RdbError = IoError; pub type RdbResult<T> = Result<T, RdbError>; pub type RdbOk = RdbResult<()>; #[derive(Debug,Copy,PartialEq)] pub enum Type { String, List, Set, SortedSet, Hash } impl Type { pub fn from_encoding(enc_type: u8) -> Type { match enc_type { encoding_type::STRING => Type::String, encoding_type::HASH | encoding_type::HASH_ZIPMAP | encoding_type::HASH_ZIPLIST => Type::Hash, encoding_type::LIST | encoding_type::LIST_ZIPLIST => Type::List, encoding_type::SET | encoding_type::SET_INTSET => Type::Set, encoding_type::ZSET | encoding_type::ZSET_ZIPLIST => Type::SortedSet, _ => { panic!("Unknown encoding type: {}", enc_type) } } } } #[derive(Copy)] pub enum EncodingType { String, LinkedList, Hashtable, Skiplist, Intset(u64), Ziplist(u64), Zipmap(u64), Quicklist }