-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for generic public key caching
The cache must be provided by the user of this crate by implementing the `PublicKeyCache` trait.
- Loading branch information
Showing
5 changed files
with
104 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use std::future::Future; | ||
|
||
use crate::crypto::RecipientKey; | ||
|
||
/// A cache for Threema public keys | ||
pub trait PublicKeyCache { | ||
/// Error returned if cache operations fail | ||
type Error: std::error::Error; | ||
|
||
/// Store a public key for `identity` in the cache | ||
fn store( | ||
&self, | ||
identity: &str, | ||
key: &RecipientKey, | ||
) -> impl Future<Output = Result<(), Self::Error>>; | ||
|
||
/// Retrieve a public key for `identity` from the cache | ||
fn load( | ||
&self, | ||
identity: &str, | ||
) -> impl Future<Output = Result<Option<RecipientKey>, Self::Error>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters