Skip to content

Commit 411ab7d

Browse files
author
Bennett Hardwick
authored
Merge pull request #25 from cipherstash/to-from-plaintext
Conversion from/to Plaintext and conversion from/to TableAttribute
2 parents 8b7e9a9 + edf11b1 commit 411ab7d

File tree

6 files changed

+517
-126
lines changed

6 files changed

+517
-126
lines changed

cryptonamo-derive/src/decryptable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ pub(crate) fn derive_decryptable(input: DeriveInput) -> Result<TokenStream, syn:
2020
let attr_ident = format_ident!("{attr}");
2121

2222
quote! {
23-
#attr_ident: unsealed.from_protected(#attr)?.to_owned().try_into()?
23+
#attr_ident: ::cryptonamo::traits::TryFromPlaintext::try_from_plaintext(unsealed.from_protected(#attr)?)?
2424
}
2525
})
2626
.chain(plaintext_attributes.iter().map(|attr| {
2727
let attr_ident = format_ident!("{attr}");
2828

2929
quote! {
30-
#attr_ident: unsealed.from_plaintext(#attr)?.try_into()?
30+
#attr_ident: ::cryptonamo::traits::TryFromTableAttr::try_from_table_attr(unsealed.from_plaintext(#attr)?)?
3131
}
3232
}))
3333
.chain(skipped_attributes.iter().map(|attr| {

cryptonamo-derive/src/encryptable.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ pub(crate) fn derive_encryptable(input: DeriveInput) -> Result<TokenStream, syn:
3636
let attr_ident = format_ident!("{attr}");
3737

3838
quote! {
39-
.add_protected(#attr, |x| cryptonamo::traits::Plaintext::from(&x.#attr_ident))
39+
.add_protected(#attr, |x| cryptonamo::traits::Plaintext::from(x.#attr_ident.to_owned()))
4040
}
4141
})
4242
.chain(plaintext_attributes.iter().map(|attr| {
4343
let attr_ident = format_ident!("{attr}");
4444

4545
quote! {
46-
.add_plaintext(#attr, |x| cryptonamo::traits::TableAttribute::from(&x.#attr_ident))
46+
.add_plaintext(#attr, |x| cryptonamo::traits::TableAttribute::from(x.#attr_ident.clone()))
4747
}
4848
}));
4949

@@ -54,7 +54,7 @@ pub(crate) fn derive_encryptable(input: DeriveInput) -> Result<TokenStream, syn:
5454
if let Some(prefix) = Self::sort_key_prefix() {
5555
format!("{}#{}", prefix, self.#sort_key_attr)
5656
} else {
57-
self.#sort_key_attr.clone()
57+
self.#sort_key_attr.to_string()
5858
}
5959
}
6060
} else {

src/encrypted_table/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pub mod query;
22
mod table_entry;
33
pub use self::{
44
query::{QueryBuilder, QueryError},
5-
table_entry::{TableAttribute, TableEntry},
5+
table_entry::{TableAttribute, TableEntry, TryFromTableAttr},
66
};
77
use crate::{
88
crypto::*,

0 commit comments

Comments
 (0)