use ActionMapper;
use error::*;
use libflo_module::ModuleMapper;
use serialization::ActionMapperSerde;
use std::collections::HashMap;
pub struct ExtActionMapper<'a, 'b> {
action_mapper: &'a ActionMapper,
module_mapper: &'b ModuleMapper,
}
impl <'a, 'b> ExtActionMapper<'a, 'b> {
pub fn new(
action_mapper: &'a ActionMapper,
module_mapper: &'b ModuleMapper,
) -> Self {
ExtActionMapper {
action_mapper: action_mapper,
module_mapper: module_mapper
}
}
pub fn get<TStr: AsRef<str>>(&self, module_id: usize, action_name: TStr) -> Result<usize> {
self.action_mapper.get(module_id, action_name).map_err(|err| err.into())
}
pub fn get_by_module_name<TStr0: AsRef<str>, TStr1: AsRef<str>>(&self, module_name: TStr0, action_name: TStr1) -> Result<usize> {
let module_id = self.module_mapper.get(module_name)?;
self.get(module_id, action_name)
}
pub fn get_raw_map(&self) -> &Vec<Option<HashMap<String, usize>>> {
self.action_mapper.get_raw_map()
}
pub fn make_serde(&self) -> ActionMapperSerde {
self.action_mapper.make_serde()
}
}