use rig::tool::ToolDyn;
pub struct ToolRegistry {
tools: Vec<Box<dyn ToolDyn>>,
}
impl ToolRegistry {
pub fn new() -> Self {
Self { tools: Vec::new() }
}
pub fn add(&mut self, tool: Box<dyn ToolDyn>) {
self.tools.push(tool);
}
pub fn remove(&mut self, index: usize) {
if index < self.tools.len() {
self.tools.remove(index);
}
}
pub fn take_all(&mut self) -> Vec<Box<dyn ToolDyn>> {
std::mem::take(&mut self.tools)
}
pub fn get_all(&self) -> &[Box<dyn ToolDyn>] {
&self.tools
}
pub fn get_all_mut(&mut self) -> &mut Vec<Box<dyn ToolDyn>> {
&mut self.tools
}
pub fn len(&self) -> usize {
self.tools.len()
}
pub fn is_empty(&self) -> bool {
self.tools.is_empty()
}
pub fn clear(&mut self) {
self.tools.clear();
}
}
impl Default for ToolRegistry {
fn default() -> Self {
Self::new()
}
}