identifiers: Add get method to Signatures

This commit is contained in:
Isaiah Inuwa 2021-06-10 15:17:11 +02:00 committed by Jonas Platte
parent 9d34524442
commit 46cf197927
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67

View File

@ -1,4 +1,4 @@
use std::collections::BTreeMap;
use std::{borrow::Borrow, collections::BTreeMap};
use crate::{DeviceIdBox, KeyNameBox, ServerNameBox, SigningKeyId, UserId};
@ -35,6 +35,15 @@ impl<E: Ord, K: ?Sized> Signatures<E, K> {
) -> Option<String> {
self.0.entry(entity).or_insert_with(Default::default).insert(key_identifier, value)
}
/// Returns a reference to the signatures corresponding to the entities.
pub fn get<Q>(&self, entity: &Q) -> Option<&EntitySignatures<K>>
where
E: Borrow<Q>,
Q: Ord + ?Sized,
{
self.0.get(entity)
}
}
/// Map of server signatures for an event, grouped by server.