Skip to content

Commit 957b679

Browse files
committed
Refactoring the sealer a bit, not sure if its better
1 parent 538dfe5 commit 957b679

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/crypto/sealer.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,16 @@ impl<T> Sealer<T> {
103103
term_length,
104104
)
105105
.map_err(SealError::CryptoError)
106-
.and_then(|index_term| match index_term {
107-
IndexTerm::Binary(x) => Ok(vec![(index_name, x)]),
108-
IndexTerm::BinaryVec(x) => {
109-
Ok(x.into_iter().map(|x| (index_name, x)).collect())
110-
}
111-
_ => Err(SealError::InvalidCiphertext("Invalid index term".into())),
112-
})
106+
.map(|result| (index_name, result))
113107
})
114108
})
109+
.map(|index_term| match index_term {
110+
Ok((index_name, IndexTerm::Binary(x))) => Ok(vec![(index_name, x)]),
111+
Ok((index_name, IndexTerm::BinaryVec(x))) => {
112+
Ok(x.into_iter().map(|x| (index_name, x)).collect())
113+
}
114+
_ => Err(SealError::InvalidCiphertext("Invalid index term".into())),
115+
})
115116
.flatten_ok()
116117
.try_collect()?;
117118

src/traits/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ pub trait Searchable: Encryptable {
5454
}
5555
}
5656

57-
/*
58-
We need to identify which fields from TableAttributes are encrypted and which are plaintext.
59-
Decrypt the ciphertexts and convert them all into the final record.
60-
Conversion would take the that were decrypted and a subset of the TableAttributes.
61-
*/
62-
6357
pub trait Decryptable: Encryptable {
6458
/// Convert an `Unsealed` into a `Self`.
6559
fn from_unsealed(unsealed: Unsealed) -> Result<Self, SealError>;

0 commit comments

Comments
 (0)