use macro_magic::export_tokens;
use crate::{
action::{deeplink, export_doc, option_setters, options_doc},
client_encryption::{ClientEncryption, MasterKey},
};
impl ClientEncryption {
#[deeplink]
#[options_doc(create_data_keys)]
pub fn create_data_key(&self, master_key: impl Into<MasterKey>) -> CreateDataKey<'_> {
CreateDataKey {
client_enc: self,
master_key: master_key.into(),
options: None,
#[cfg(test)]
test_kms_provider: None,
}
}
}
#[must_use]
pub struct CreateDataKey<'a> {
pub(crate) client_enc: &'a ClientEncryption,
pub(crate) master_key: MasterKey,
pub(crate) options: Option<DataKeyOptions>,
#[cfg(test)]
pub(crate) test_kms_provider: Option<mongocrypt::ctx::KmsProvider>,
}
#[derive(Debug, Clone, Default)]
#[non_exhaustive]
#[export_tokens]
pub struct DataKeyOptions {
pub key_alt_names: Option<Vec<String>>,
pub key_material: Option<Vec<u8>>,
}
#[option_setters(DataKeyOptions)]
#[export_doc(create_data_keys)]
impl CreateDataKey<'_> {
#[cfg(test)]
pub(crate) fn test_kms_provider(mut self, value: mongocrypt::ctx::KmsProvider) -> Self {
self.test_kms_provider = Some(value);
self
}
}