diff options
-rw-r--r-- | net/src/lib.rs | 7 | ||||
-rw-r--r-- | openpgp/src/lib.rs | 1 | ||||
-rw-r--r-- | openpgp/src/types.rs | 21 | ||||
-rw-r--r-- | tool/src/main.rs | 9 |
4 files changed, 9 insertions, 29 deletions
diff --git a/net/src/lib.rs b/net/src/lib.rs index 651ace16..63ac9c2b 100644 --- a/net/src/lib.rs +++ b/net/src/lib.rs @@ -58,8 +58,7 @@ use std::io; use sequoia_core::{Context, NetworkPolicy}; use openpgp::tpk::{self, TPK}; -use openpgp::types::KeyId; -use openpgp::{Message, armor}; +use openpgp::{Message, KeyID, armor}; pub mod ipc; @@ -156,9 +155,9 @@ impl KeyServer { } /// Retrieves the key with the given `keyid`. - pub fn get(&mut self, keyid: &KeyId) -> Result<TPK> { + pub fn get(&mut self, keyid: &KeyID) -> Result<TPK> { let uri = format!("{}/pks/lookup?op=get&options=mr&search=0x{}", - self.uri, keyid.as_hex()).parse()?; + self.uri, keyid.to_hex()).parse()?; let result = self.core.run( self.client.do_get(uri).and_then(|res| { let status = res.status(); diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs index 182a2761..f2b27f3f 100644 --- a/openpgp/src/lib.rs +++ b/openpgp/src/lib.rs @@ -58,7 +58,6 @@ use std::collections::HashMap; pub mod armor; pub mod parse; pub mod tpk; -pub mod types; pub mod serialize; mod unknown; diff --git a/openpgp/src/types.rs b/openpgp/src/types.rs deleted file mode 100644 index 5ad32631..00000000 --- a/openpgp/src/types.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! Types for working with OpenPGP. - -/// Uniquely identifies OpenPGP keys. -pub struct KeyId(u64); - -impl KeyId { - /// Returns a KeyID with the given `id`. - pub fn new(id: u64) -> KeyId { - KeyId(id) - } - - /// Returns a KeyID with the given `id` encoded as hexadecimal string. - pub fn from_hex(id: &str) -> Option<KeyId> { - u64::from_str_radix(id, 16).ok().map(|id| Self::new(id)) - } - - /// Returns a hexadecimal representation of the key id. - pub fn as_hex(&self) -> String { - format!("{:x}", self.0) - } -} diff --git a/tool/src/main.rs b/tool/src/main.rs index 0df05a36..b7e91ca2 100644 --- a/tool/src/main.rs +++ b/tool/src/main.rs @@ -250,11 +250,14 @@ fn real_main() -> Result<()> { match m.subcommand() { ("get", Some(m)) => { let keyid = m.value_of("keyid").unwrap(); - let id = openpgp::types::KeyId::from_hex(keyid); + let id = openpgp::KeyID::from_hex(keyid); if id.is_none() { - eprintln!("Malformed keyid: {:?}", keyid); + eprintln!("Malformed key ID: \"{:?}\"\n\ + (Note: only long Key IDs are supported.)", + keyid); exit(1); } + let id = id.unwrap(); let mut output = create_or_stdout(m.value_of("output")); let mut output = if m.is_present("armor") { @@ -263,7 +266,7 @@ fn real_main() -> Result<()> { output }; - ks.get(&id.unwrap()).expect("An error occured") + ks.get(&id).expect("An error occured") .serialize(&mut output).expect("An error occured"); }, ("send", Some(m)) => { |