Skip to content

Commit 347c728

Browse files
author
Nicklas Warming Jacobsen
committed
Add trait TryFromTableAttribute
* Add trait `TryFromTableAttribute` instead of using `TryFrom<TableAttribute> for T` * Replace all the different macros in table_entry.rs with 1 single macro * Blanket `impl<T: Into<TableAttribute>> From<Option<T>> for TableAttribute` * Blanket `impl<T: Into<TableAttribute>> From<Vec<T>> for TableAttribute` * Blanket `impl<T: TryFromTableAttribute> TryFromTableAttribute for Option<T>` * Blanket `impl<T: TryFromTableAttribute> TryFromTableAttribute for Vec<T>` * Fix the derive macros to use the new traits
1 parent c3344cf commit 347c728

File tree

5 files changed

+351
-119
lines changed

5 files changed

+351
-119
lines changed

cryptonamo-derive/src/decryptable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(crate) fn derive_decryptable(input: DeriveInput) -> Result<TokenStream, syn:
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub(crate) fn derive_encryptable(input: DeriveInput) -> Result<TokenStream, syn:
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

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)