refactor statustype

This commit is contained in:
ModulatingForce 2024-03-20 23:35:56 -04:00
parent ca3bca9ae6
commit b353589576

View file

@ -58,7 +58,7 @@ pub enum StatusLvl {
}
#[derive(Debug)]
pub enum ModStatusType {
pub enum StatusType {
Enabled(StatusLvl),
Disabled(StatusLvl),
}
@ -177,7 +177,7 @@ pub struct Routine {}
pub struct ModulesManager {
// statusdb: Arc<RwLock<HashMap<ModType, Vec<ModStatusType>>>>,
statusdb: Arc<RwLock<HashMap<(ModType,ModGroup), Vec<ModStatusType>>>>,
statusdb: Arc<RwLock<HashMap<(ModType,ModGroup), Vec<StatusType>>>>,
pub botactions: Arc<RwLock<HashMap<ModType, Vec<BotAction>>>>,
}
@ -226,7 +226,7 @@ impl ModulesManager {
mgrarc
}
pub fn modstatus(&self, _: ModType, _: ChType) -> ModStatusType {
pub fn modstatus(&self, _: ModType, _: ChType) -> StatusType {
// Example usage : botmanager.modstatus(
// BotModule("GambaCore"),
// Channel("modulatingforce")
@ -234,15 +234,15 @@ impl ModulesManager {
// - The ModStatusType checks in the context of the given channel ,
// but also validates based on wheher the module is disabled at a bot instance
// level as well
ModStatusType::Enabled(StatusLvl::Instance)
StatusType::Enabled(StatusLvl::Instance)
}
pub fn togglestatus(&self, _: ModType, _: ChType) -> ModStatusType {
pub fn togglestatus(&self, _: ModType, _: ChType) -> StatusType {
// enables or disables based on current status
ModStatusType::Enabled(StatusLvl::Instance)
StatusType::Enabled(StatusLvl::Instance)
}
pub fn setstatus(&self, _: ModType, _: ModStatusType) -> Result<&str, Box<dyn Error>> {
pub fn setstatus(&self, _: ModType, _: StatusType) -> Result<&str, Box<dyn Error>> {
// sets the status based given ModSatusType
// e.g., b.setstatus(BodModule("GambaCore"), Enabled(Channel("modulatingforce"))).expect("ERROR")
Ok("")
@ -341,8 +341,8 @@ impl ModulesManager {
let statusvector = dbt.entry((in_module.clone(),in_modgroup.clone())).or_insert(Vec::new());
match in_modgroup {
ModGroup::Core => statusvector.push(ModStatusType::Enabled(StatusLvl::Instance)) , // Pushes the Module as Enabled at Instance Level
ModGroup::Custom => statusvector.push(ModStatusType::Disabled(StatusLvl::Instance)),
ModGroup::Core => statusvector.push(StatusType::Enabled(StatusLvl::Instance)) , // Pushes the Module as Enabled at Instance Level
ModGroup::Custom => statusvector.push(StatusType::Disabled(StatusLvl::Instance)),
}
// statusvector.push(ModStatusType::Enabled(StatusLvl::Instance)); // Pushes the Module as Enabled at Instance Level