From 46cf1979277cd943213bac88b6653536a01d0f09 Mon Sep 17 00:00:00 2001 From: Isaiah Inuwa Date: Thu, 10 Jun 2021 15:17:11 +0200 Subject: [PATCH] identifiers: Add get method to Signatures --- crates/ruma-identifiers/src/signatures.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/ruma-identifiers/src/signatures.rs b/crates/ruma-identifiers/src/signatures.rs index 9400bde3..b04d2fe4 100644 --- a/crates/ruma-identifiers/src/signatures.rs +++ b/crates/ruma-identifiers/src/signatures.rs @@ -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 Signatures { ) -> Option { 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(&self, entity: &Q) -> Option<&EntitySignatures> + where + E: Borrow, + Q: Ord + ?Sized, + { + self.0.get(entity) + } } /// Map of server signatures for an event, grouped by server.