headless_lms_chatbot/chatbot_tools/
tool_category.rs1use headless_lms_models::chatbot_configurations::{ChatbotConfiguration, ToolCategory};
6
7pub struct EnabledToolCategories(Vec<ToolCategory>);
8
9impl EnabledToolCategories {
10 pub fn from_configuration(configuration: &ChatbotConfiguration) -> Self {
11 Self(configuration.enabled_tool_categories.clone())
12 }
13
14 pub fn contains(&self, category: ToolCategory) -> bool {
15 self.0.contains(&category)
16 }
17
18 pub fn is_empty(&self) -> bool {
19 self.0.is_empty()
20 }
21
22 #[cfg(test)]
23 pub(crate) fn all() -> Self {
24 Self(ToolCategory::ALL.to_vec())
25 }
26
27 #[cfg(test)]
28 pub(crate) fn only(categories: &[ToolCategory]) -> Self {
29 Self(categories.to_vec())
30 }
31}