Added a database cache type.
This commit is contained in:
		@@ -14,6 +14,7 @@ impl Databases {
 | 
			
		||||
pub enum CacheType {
 | 
			
		||||
    Raw(String),
 | 
			
		||||
    DBMap(Databases),
 | 
			
		||||
    TableMap,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl CacheType {
 | 
			
		||||
@@ -21,6 +22,7 @@ impl CacheType {
 | 
			
		||||
        match self {
 | 
			
		||||
            CacheType::Raw(_) => "Raw".to_string(),
 | 
			
		||||
            CacheType::DBMap(_) => "DBMap".to_string(),
 | 
			
		||||
            CacheType::TableMap => "TableMap".to_string(),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -30,6 +32,7 @@ impl CacheType {
 | 
			
		||||
        match self {
 | 
			
		||||
            CacheType::Raw(s) => output.append(&mut s.as_bytes().to_vec()),
 | 
			
		||||
            CacheType::DBMap(_) => (),
 | 
			
		||||
            CacheType::TableMap => (),
 | 
			
		||||
        }
 | 
			
		||||
        return output;
 | 
			
		||||
    }
 | 
			
		||||
@@ -69,6 +72,7 @@ impl fmt::Display for CacheType {
 | 
			
		||||
        match self {
 | 
			
		||||
            CacheType::Raw(s) => write!(f, "{}", s),
 | 
			
		||||
            CacheType::DBMap(_) => todo!(),
 | 
			
		||||
            CacheType::TableMap => todo!(),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -168,4 +172,10 @@ mod enum_ctype {
 | 
			
		||||
        let output = CacheType::from_bytes(data).unwrap();
 | 
			
		||||
        assert_eq!(output.entry_type(), "DBMap");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn get_tablemap_type() {
 | 
			
		||||
        let holder = CacheType::TableMap;
 | 
			
		||||
        assert_eq!(holder.entry_type(), "TableMap");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user