checkpoint
This commit is contained in:
		| @@ -201,8 +201,18 @@ impl TypedKeySet { | ||||
|             self.remove(*k); | ||||
|         } | ||||
|     } | ||||
|     /// Return preferred typed key of our supported crypto kinds | ||||
|     pub fn best(&self) -> Option<TypedKey> { | ||||
|         self.items.first().copied() | ||||
|         match self.items.first().copied() { | ||||
|             None => None, | ||||
|             Some(k) => { | ||||
|                 if !VALID_CRYPTO_KINDS.contains(&k.kind) { | ||||
|                     None | ||||
|                 } else { | ||||
|                     Some(k) | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     pub fn len(&self) -> usize { | ||||
|         self.items.len() | ||||
| @@ -221,6 +231,14 @@ impl TypedKeySet { | ||||
|         } | ||||
|         false | ||||
|     } | ||||
|     pub fn contains_key(&self, key: &PublicKey) -> bool { | ||||
|         for tk in &self.items { | ||||
|             if tk.key == *key { | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         false | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl core::ops::Deref for TypedKeySet { | ||||
| @@ -264,6 +282,13 @@ impl FromStr for TypedKeySet { | ||||
|         Ok(Self { items }) | ||||
|     } | ||||
| } | ||||
| impl From<TypedKey> for TypedKeySet { | ||||
|     fn from(x: TypedKey) -> Self { | ||||
|         let mut tks = TypedKeySet::with_capacity(1); | ||||
|         tks.add(x); | ||||
|         tks | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[derive( | ||||
|     Clone, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user