Unregister a tool
(&self, name: &str)
| 154 | |
| 155 | /// Unregister a tool |
| 156 | pub fn unregister_tool(&self, name: &str) -> PyResult<bool> { |
| 157 | let mut tools = self.tools.write().map_err(|e| { |
| 158 | PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(format!( |
| 159 | "Failed to acquire tools lock: {}", |
| 160 | e |
| 161 | )) |
| 162 | })?; |
| 163 | |
| 164 | let mut metadata = self.metadata.write().map_err(|e| { |
| 165 | PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(format!( |
| 166 | "Failed to acquire metadata lock: {}", |
| 167 | e |
| 168 | )) |
| 169 | })?; |
| 170 | |
| 171 | let removed_tool = tools.remove(name).is_some(); |
| 172 | let removed_meta = metadata.remove(name).is_some(); |
| 173 | |
| 174 | Ok(removed_tool || removed_meta) |
| 175 | } |
| 176 | |
| 177 | /// Check if a tool is registered |
| 178 | pub fn has_tool(&self, name: &str) -> PyResult<bool> { |