1use jsonwebtoken::DecodingKey;
7use std::collections::HashMap;
8
9pub struct KeySet {
10 keys: HashMap<String, DecodingKey>,
11}
12
13impl KeySet {
14 #[must_use]
15 pub fn new() -> Self {
16 Self {
17 keys: HashMap::new(),
18 }
19 }
20
21 pub fn insert(&mut self, kid: impl Into<String>, key: DecodingKey) {
22 self.keys.insert(kid.into(), key);
23 }
24
25 pub(crate) fn get(&self, kid: &str) -> Option<&DecodingKey> {
26 self.keys.get(kid)
27 }
28}
29
30impl Default for KeySet {
31 fn default() -> Self {
32 Self::new()
33 }
34}
35
36impl std::fmt::Debug for KeySet {
38 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
39 f.debug_struct("KeySet")
40 .field("kids", &self.keys.keys().collect::<Vec<_>>())
41 .finish_non_exhaustive()
42 }
43}