use crate::ui::{ambient::with_storage, module};
#[module]
pub(crate) struct Storage;
#[module]
impl Storage {
pub(crate) async fn get_item(key: String) -> Option<String> {
with_storage(|s| s.get(&key))
}
pub(crate) async fn set_item(key: String, value: String) -> Result<(), String> {
with_storage(|s| s.set(key, value)).map_err(|e| e.to_string())
}
pub(crate) async fn remove_item(key: String) -> Result<(), String> {
with_storage(|s| s.remove(&key));
Ok(())
}
pub(crate) async fn keys() -> Vec<String> {
with_storage(|s| s.keys())
}
pub(crate) async fn clear() -> Result<(), String> {
with_storage(|s| s.clear());
Ok(())
}
}