From 84cbdb35c492c292b4c737ae37cc60523b499984 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 18 Jan 2021 12:14:05 +0100 Subject: [PATCH] implement FromStr for Fingerprint --- src/backup/crypt_config.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/backup/crypt_config.rs b/src/backup/crypt_config.rs index 92601f61..9efc9cf8 100644 --- a/src/backup/crypt_config.rs +++ b/src/backup/crypt_config.rs @@ -63,6 +63,17 @@ impl Display for Fingerprint { } } +impl std::str::FromStr for Fingerprint { + type Err = Error; + + fn from_str(s: &str) -> Result { + let mut tmp = s.to_string(); + tmp.retain(|c| c != ':'); + let bytes = proxmox::tools::hex_to_digest(&tmp)?; + Ok(Fingerprint::new(bytes)) + } +} + /// Encryption Configuration with secret key /// /// This structure stores the secret key and provides helpers for