handle memory clear errors

This commit is contained in:
yggverse 2024-11-23 11:48:02 +02:00
parent efa3bc48c3
commit 8a4e979d48
8 changed files with 33 additions and 11 deletions

View file

@ -1,4 +1,4 @@
mod error;
pub mod error;
pub use error::Error;
use std::{cell::RefCell, collections::HashMap};
@ -34,8 +34,14 @@ impl Memory {
}
/// Cleanup index
pub fn clear(&self) {
self.index.borrow_mut().clear()
pub fn clear(&self) -> Result<(), Error> {
let mut index = self.index.borrow_mut();
index.clear();
if index.is_empty() {
Ok(())
} else {
Err(Error::Clear)
}
}
/// Get `profile_identity_gemini_id` vector match given `request`