use std::collections::BTreeMap;
use crate::{DeviceIdBox, KeyNameBox, ServerNameBox, SigningKeyId, UserId};
pub type EntitySignatures<K> = BTreeMap<SigningKeyId<K>, String>;
#[derive(Clone, Debug, Default)]
pub struct Signatures<E: Ord, K: ?Sized>(BTreeMap<E, EntitySignatures<K>>);
impl<E: Ord, K: ?Sized> Signatures<E, K> {
pub fn new() -> Self {
Self(BTreeMap::new())
}
pub fn insert(
&mut self,
entity: E,
key_identifier: SigningKeyId<K>,
value: String,
) -> Option<String> {
self.0.entry(entity).or_insert_with(Default::default).insert(key_identifier, value)
}
}
pub type ServerSignatures = Signatures<ServerNameBox, KeyNameBox>;
pub type DeviceSignatures = Signatures<UserId, DeviceIdBox>;