diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-08-24 14:59:49 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-08-24 14:59:49 +0200 |
commit | 30f525ee2a7b92f17878704f4bcc3cafe6006dde (patch) | |
tree | 5784f8f6bd38e14fb3cd7ba063d55d762c331297 /openpgp/src/fingerprint.rs | |
parent | e0f20bbf1462957277119607ca2c0424fc657885 (diff) |
openpgp: Make functions parsing key ids, fingerprints return Result.
- Fixes #13.
Diffstat (limited to 'openpgp/src/fingerprint.rs')
-rw-r--r-- | openpgp/src/fingerprint.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/openpgp/src/fingerprint.rs b/openpgp/src/fingerprint.rs index 1f090d83..b0ad4f1d 100644 --- a/openpgp/src/fingerprint.rs +++ b/openpgp/src/fingerprint.rs @@ -2,6 +2,7 @@ use std::fmt; use Fingerprint; use KeyID; +use Result; impl fmt::Display for Fingerprint { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -39,11 +40,11 @@ impl Fingerprint { /// # use openpgp::Fingerprint; /// let hex = "3E8877C877274692975189F5D03F6F865226FE8B"; /// let fp = Fingerprint::from_hex(hex); - /// assert!(fp.is_some()); + /// assert!(fp.is_ok()); /// assert_eq!(fp.unwrap().to_hex(), hex); /// ``` - pub fn from_hex(hex: &str) -> Option<Fingerprint> { - Some(Fingerprint::from_bytes(&::conversions::from_hex(hex, true)?[..])) + pub fn from_hex(hex: &str) -> Result<Fingerprint> { + Ok(Fingerprint::from_bytes(&::conversions::from_hex(hex, true)?[..])) } /// Returns a reference to the raw Fingerprint. |