use alloc::{rc::Rc, string::String, vec::Vec}; use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, mutex::Mutex}; use serde::{Deserialize, Serialize}; use crate::store::{persistence::Persistence, tally_id::TallyID}; #[derive(Clone, Serialize, Deserialize)] pub struct Name { pub first: String, pub last: String, } pub struct MappingLoader(Rc>); impl MappingLoader { pub fn new(persistence_layer: Rc>) -> Self { Self(persistence_layer) } pub async fn get_mapping(&self, id: TallyID) -> Result { self.0.lock().await.load_mapping_for_id(id).await } pub async fn set_mapping(&self, id: TallyID, name: Name) -> Result<(), T::Error> { self.0.lock().await.save_mapping_for_id(id, name).await } pub async fn list_mappings(&self) -> Result,T::Error> { self.0.lock().await.list_mappings().await } }