| 215 | } |
| 216 | |
| 217 | pub fn unregister(&self, search_function: PyObjectRef) -> PyResult<()> { |
| 218 | let mut inner = self.inner.write(); |
| 219 | // Do nothing if search_path is not created yet or was cleared. |
| 220 | if inner.search_path.is_empty() { |
| 221 | return Ok(()); |
| 222 | } |
| 223 | for (i, item) in inner.search_path.iter().enumerate() { |
| 224 | if item.get_id() == search_function.get_id() { |
| 225 | if !inner.search_cache.is_empty() { |
| 226 | inner.search_cache.clear(); |
| 227 | } |
| 228 | inner.search_path.remove(i); |
| 229 | return Ok(()); |
| 230 | } |
| 231 | } |
| 232 | Ok(()) |
| 233 | } |
| 234 | |
| 235 | pub(crate) fn register_manual(&self, name: &str, codec: PyCodec) -> PyResult<()> { |
| 236 | let name = normalize_encoding_name(name); |