mirror of
https://github.com/chatmail/core.git
synced 2026-04-21 15:36:30 +03:00
Remove unused KeyType from DcKey trait
It always equals Self.
This commit is contained in:
24
src/key.rs
24
src/key.rs
@@ -30,17 +30,13 @@ pub use pgp::composed::{SignedPublicKey, SignedSecretKey};
|
|||||||
/// [SignedSecretKey] types and makes working with them a little
|
/// [SignedSecretKey] types and makes working with them a little
|
||||||
/// easier in the deltachat world.
|
/// easier in the deltachat world.
|
||||||
pub trait DcKey: Serialize + Deserializable + KeyTrait + Clone {
|
pub trait DcKey: Serialize + Deserializable + KeyTrait + Clone {
|
||||||
type KeyType: Serialize + Deserializable + KeyTrait + Clone;
|
|
||||||
|
|
||||||
/// Create a key from some bytes.
|
/// Create a key from some bytes.
|
||||||
fn from_slice(bytes: &[u8]) -> Result<Self::KeyType> {
|
fn from_slice(bytes: &[u8]) -> Result<Self> {
|
||||||
Ok(<Self::KeyType as Deserializable>::from_bytes(Cursor::new(
|
Ok(<Self as Deserializable>::from_bytes(Cursor::new(bytes))?)
|
||||||
bytes,
|
|
||||||
))?)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a key from a base64 string.
|
/// Create a key from a base64 string.
|
||||||
fn from_base64(data: &str) -> Result<Self::KeyType> {
|
fn from_base64(data: &str) -> Result<Self> {
|
||||||
// strip newlines and other whitespace
|
// strip newlines and other whitespace
|
||||||
let cleaned: String = data.split_whitespace().collect();
|
let cleaned: String = data.split_whitespace().collect();
|
||||||
let bytes = base64::decode(cleaned.as_bytes())?;
|
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
|
/// Returns the key and a map of any headers which might have been set in
|
||||||
/// the ASCII-armored representation.
|
/// the ASCII-armored representation.
|
||||||
fn from_asc(data: &str) -> Result<(Self::KeyType, BTreeMap<String, String>)> {
|
fn from_asc(data: &str) -> Result<(Self, BTreeMap<String, String>)> {
|
||||||
let bytes = data.as_bytes();
|
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.
|
/// Load the users' default key from the database.
|
||||||
fn load_self<'a>(
|
fn load_self<'a>(
|
||||||
context: &'a Context,
|
context: &'a Context,
|
||||||
) -> Pin<Box<dyn Future<Output = Result<Self::KeyType>> + 'a + Send>>;
|
) -> Pin<Box<dyn Future<Output = Result<Self>> + 'a + Send>>;
|
||||||
|
|
||||||
/// Serialise the key as bytes.
|
/// Serialise the key as bytes.
|
||||||
fn to_bytes(&self) -> Vec<u8> {
|
fn to_bytes(&self) -> Vec<u8> {
|
||||||
@@ -92,11 +88,9 @@ pub trait DcKey: Serialize + Deserializable + KeyTrait + Clone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DcKey for SignedPublicKey {
|
impl DcKey for SignedPublicKey {
|
||||||
type KeyType = SignedPublicKey;
|
|
||||||
|
|
||||||
fn load_self<'a>(
|
fn load_self<'a>(
|
||||||
context: &'a Context,
|
context: &'a Context,
|
||||||
) -> Pin<Box<dyn Future<Output = Result<Self::KeyType>> + 'a + Send>> {
|
) -> Pin<Box<dyn Future<Output = Result<Self>> + 'a + Send>> {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let addr = context.get_primary_self_addr().await?;
|
let addr = context.get_primary_self_addr().await?;
|
||||||
match context
|
match context
|
||||||
@@ -143,11 +137,9 @@ impl DcKey for SignedPublicKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DcKey for SignedSecretKey {
|
impl DcKey for SignedSecretKey {
|
||||||
type KeyType = SignedSecretKey;
|
|
||||||
|
|
||||||
fn load_self<'a>(
|
fn load_self<'a>(
|
||||||
context: &'a Context,
|
context: &'a Context,
|
||||||
) -> Pin<Box<dyn Future<Output = Result<Self::KeyType>> + 'a + Send>> {
|
) -> Pin<Box<dyn Future<Output = Result<Self>> + 'a + Send>> {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
match context
|
match context
|
||||||
.sql
|
.sql
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ where
|
|||||||
|
|
||||||
impl<T> Keyring<T>
|
impl<T> Keyring<T>
|
||||||
where
|
where
|
||||||
T: DcKey<KeyType = T>,
|
T: DcKey,
|
||||||
{
|
{
|
||||||
/// New empty keyring.
|
/// New empty keyring.
|
||||||
pub fn new() -> Keyring<T> {
|
pub fn new() -> Keyring<T> {
|
||||||
|
|||||||
Reference in New Issue
Block a user