use crate::{
cdk::structures::{BTreeMap, DefaultMemoryImpl, memory::VirtualMemory},
storage::{prelude::*, stable::memory::topology::APP_REGISTRY_ID},
};
use std::cell::RefCell;
eager_static! {
static APP_REGISTRY: RefCell<BTreeMap<Principal, Principal, VirtualMemory<DefaultMemoryImpl>>> =
RefCell::new(BTreeMap::init(ic_memory!(AppRegistry, APP_REGISTRY_ID)));
}
#[derive(Clone, Debug)]
pub struct AppRegistryRecord {
pub entries: Vec<(Principal, Principal)>,
}
pub struct AppRegistry;
impl AppRegistry {
#[must_use]
pub(crate) fn export() -> AppRegistryRecord {
AppRegistryRecord {
entries: APP_REGISTRY
.with_borrow(|map| map.iter().map(|e| (*e.key(), e.value())).collect()),
}
}
}