use std::collections::HashMap;

use common::error::Errno;
use crate::types::WriteStoreType;


pub struct WriteStoreMgr {
    write_stores: HashMap<u32, WriteStoreType>,
}

impl WriteStoreMgr {
    pub fn new() -> Self {
        let mut write_stores = HashMap::new();
        write_stores.insert(1, WriteStoreType::Cache);
        write_stores.insert(2, WriteStoreType::Backend);
        WriteStoreMgr {
            write_stores: write_stores,
        }
    }

    pub fn get_write_store_type(&self, write_store_type: u32) -> Result<WriteStoreType, Errno> {
        if let Some(t) = self.write_stores.get(&write_store_type) {
            return Ok(t.clone());
        }

        return Err(Errno::Enoent);
    }
}
