mirror of
https://github.com/Djeeberjr/fw-anwesenheit.git
synced 2026-05-01 02:59:09 +00:00
33 lines
650 B
Rust
33 lines
650 B
Rust
use alloc::collections::BTreeMap;
|
|
use alloc::string::String;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::store::tally_id::TallyID;
|
|
|
|
#[derive(Clone, Serialize, Deserialize)]
|
|
pub struct Name {
|
|
pub first: String,
|
|
pub last: String,
|
|
}
|
|
|
|
#[derive(Clone, Serialize)]
|
|
pub struct IDMapping {
|
|
id_map: BTreeMap<TallyID, Name>,
|
|
}
|
|
|
|
impl IDMapping {
|
|
pub fn new() -> Self {
|
|
IDMapping {
|
|
id_map: BTreeMap::new(),
|
|
}
|
|
}
|
|
|
|
pub fn map(&self, id: &TallyID) -> Option<&Name> {
|
|
self.id_map.get(id)
|
|
}
|
|
|
|
pub fn add_mapping(&mut self, id: TallyID, name: Name) {
|
|
self.id_map.insert(id, name);
|
|
}
|
|
}
|