the state before switching to dynamic dispatch for stores

This commit is contained in:
Sebastian Moser
2024-06-09 14:01:25 +02:00
parent 6887287c29
commit 33e75d9c25
9 changed files with 229 additions and 6 deletions

View File

@@ -130,7 +130,19 @@ impl<S: Store> Instance<S> {
//fn from(value: T) -> Self {
//}
//}
pub fn migrate_to_store<New: Store>(&mut self, new_store: New) -> MizeResult<Instance<New>> {
let old_store = self.store;
for id in old_store.id_iter()? {
let data = self.store.get_value_data_full(self.id_from_string(id))?;
let id_of_new_store = new_store.new_id()?;
new_store.set(self.id_from_string(id_of_new_store), data.to_owned())?;
};
self.store = new_store as S;
Ok(Instance { store: new_store, subs: self.subs, peers: self.peers, id_pool: self.id_pool })
}
}
impl<S: Store> fmt::Debug for Instance<S> {