bitwarden_crypto/traits/
mod.rs

1mod encryptable;
2pub use encryptable::Encryptable;
3mod decryptable;
4pub use decryptable::Decryptable;
5
6pub(crate) mod key_id;
7pub use key_id::{KeyId, KeyIds};
8
9/// Types implementing [IdentifyKey] are capable of knowing which cryptographic key is
10/// needed to encrypt/decrypt them.
11pub trait IdentifyKey<Key: KeyId> {
12    fn key_identifier(&self) -> Key;
13}
14
15#[cfg(test)]
16pub(crate) mod tests {
17    use crate::key_ids;
18    key_ids! {
19        #[symmetric]
20        pub enum TestSymmKey {
21            A(u8),
22
23            // We only support one variant value,
24            // but that value can be a tuple
25            B((u8, u8)),
26
27            #[local]
28            C(u8),
29        }
30
31        #[asymmetric]
32        pub enum TestAsymmKey {
33            A(u8),
34            B,
35            #[local]
36            C(&'static str),
37        }
38
39       pub TestIds => TestSymmKey, TestAsymmKey;
40    }
41}