v0.8.0
What's Changed
- Encrypt with by @coderdan in #77
- Bumped version to 0.8.0 by @coderdan in #79
- Bumped cipherstash-dynamodb-derive to 0.8.0 and updated dep by @coderdan in #80
Derive macros
Adds support for custom field functions so that arbitrary types can be added to Unsealed
and encrypted.
For example, to handle a field with a BTreeMap
:
#[derive(Debug, Clone, PartialEq, Searchable, Encryptable, Decryptable, Identifiable)]
struct Test {
#[partition_key]
pub pk: String,
#[sort_key]
pub sk: String,
pub name: String,
pub age: i16,
#[cipherstash(plaintext)]
pub tag: String,
#[cipherstash(encryptable_with = put_attrs, decryptable_with = get_attrs)]
pub attrs: BTreeMap<String, String>,
}
fn put_attrs(unsealed: &mut Unsealed, attrs: BTreeMap<String, String>) {
attrs.into_iter().for_each(|(k, v)| {
unsealed.add_protected_map_field("attrs", k, Plaintext::from(v));
})
}
fn get_attrs<T>(unsealed: &mut Unsealed) -> Result<T, SealError>
where
T: FromIterator<(String, String)>,
{
unsealed
.take_protected_map("attrs")
.ok_or(TypeParseError("attrs".to_string()))?
.into_iter()
.map(|(k, v)| {
TryFromPlaintext::try_from_plaintext(v)
.map(|v| (k, v))
.map_err(SealError::from)
})
.collect()
}
Full Changelog: v0.7.4...v0.8.0