Skip to content

Commit 7f52fb0

Browse files
committed
Add docs
1 parent d1f8029 commit 7f52fb0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

crates/bitwarden-crypto/src/keys/key_encryptable.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,22 @@ impl<T: KeyContainer> KeyContainer for Arc<T> {
1919
#[allow(missing_docs)]
2020
pub trait CryptoKey {}
2121

22-
#[allow(missing_docs)]
22+
/// An encryption operation that takes the input value and encrypts it into the output value
23+
/// using a key reference. Implementing this requires a content type to be specified in
24+
/// the implementation.
2325
pub trait KeyEncryptable<Key: CryptoKey, Output> {
26+
/// Encrypts a value using the provided key reference.
2427
fn encrypt_with_key(self, key: &Key) -> Result<Output>;
2528
}
2629

30+
/// An encryption operation that takes the input value and encrypts it into the output value
31+
/// using a key reference, with an externally provided content type.
32+
///
33+
/// In contrast to `KeyEncryptable`, this trait allows the caller to specify the content format.
34+
/// Because of this, it is not exposed outside of the crate, because outside callers should
35+
/// not make a choice about the content format. Where possible, the content format is
36+
/// ensured at compile time by the type system, not at runtime by the caller passing
37+
/// in a parameter.
2738
pub(crate) trait KeyEncryptableWithContentType<Key: CryptoKey, Output> {
2839
fn encrypt_with_key(self, key: &Key, content_format: ContentFormat) -> Result<Output>;
2940
}

0 commit comments

Comments
 (0)