diff --git a/src/key.rs b/src/key.rs index e2fbe7c82..82ea25667 100644 --- a/src/key.rs +++ b/src/key.rs @@ -30,17 +30,13 @@ pub use pgp::composed::{SignedPublicKey, SignedSecretKey}; /// [SignedSecretKey] types and makes working with them a little /// easier in the deltachat world. pub trait DcKey: Serialize + Deserializable + KeyTrait + Clone { - type KeyType: Serialize + Deserializable + KeyTrait + Clone; - /// Create a key from some bytes. - fn from_slice(bytes: &[u8]) -> Result { - Ok(::from_bytes(Cursor::new( - bytes, - ))?) + fn from_slice(bytes: &[u8]) -> Result { + Ok(::from_bytes(Cursor::new(bytes))?) } /// Create a key from a base64 string. - fn from_base64(data: &str) -> Result { + fn from_base64(data: &str) -> Result { // strip newlines and other whitespace let cleaned: String = data.split_whitespace().collect(); let bytes = base64::decode(cleaned.as_bytes())?; @@ -51,15 +47,15 @@ pub trait DcKey: Serialize + Deserializable + KeyTrait + Clone { /// /// Returns the key and a map of any headers which might have been set in /// the ASCII-armored representation. - fn from_asc(data: &str) -> Result<(Self::KeyType, BTreeMap)> { + fn from_asc(data: &str) -> Result<(Self, BTreeMap)> { let bytes = data.as_bytes(); - Self::KeyType::from_armor_single(Cursor::new(bytes)).context("rPGP error") + Self::from_armor_single(Cursor::new(bytes)).context("rPGP error") } /// Load the users' default key from the database. fn load_self<'a>( context: &'a Context, - ) -> Pin> + 'a + Send>>; + ) -> Pin> + 'a + Send>>; /// Serialise the key as bytes. fn to_bytes(&self) -> Vec { @@ -92,11 +88,9 @@ pub trait DcKey: Serialize + Deserializable + KeyTrait + Clone { } impl DcKey for SignedPublicKey { - type KeyType = SignedPublicKey; - fn load_self<'a>( context: &'a Context, - ) -> Pin> + 'a + Send>> { + ) -> Pin> + 'a + Send>> { Box::pin(async move { let addr = context.get_primary_self_addr().await?; match context @@ -143,11 +137,9 @@ impl DcKey for SignedPublicKey { } impl DcKey for SignedSecretKey { - type KeyType = SignedSecretKey; - fn load_self<'a>( context: &'a Context, - ) -> Pin> + 'a + Send>> { + ) -> Pin> + 'a + Send>> { Box::pin(async move { match context .sql diff --git a/src/keyring.rs b/src/keyring.rs index 192b8de80..fa5e9b5f4 100644 --- a/src/keyring.rs +++ b/src/keyring.rs @@ -19,7 +19,7 @@ where impl Keyring where - T: DcKey, + T: DcKey, { /// New empty keyring. pub fn new() -> Keyring {