Skip to content

Commit 3142867

Browse files
committed
More refactoring
1 parent 7642db9 commit 3142867

2 files changed

Lines changed: 7 additions & 15 deletions

File tree

src/crypto/sealed.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@ use super::{attrs::NormalizedProtectedAttributes, SealError, Unsealed};
1717
/// Wrapped to indicate that the value is encrypted
1818
pub struct SealedTableEntry(pub(super) TableEntry);
1919

20-
// TODO: Remove this
2120
pub struct UnsealSpec<'a> {
2221
pub protected_attributes: Cow<'a, [Cow<'a, str>]>,
23-
pub plaintext_attributes: Cow<'a, [Cow<'a, str>]>,
2422
}
2523

2624
impl UnsealSpec<'static> {
2725
pub fn new_for_decryptable<D: Decryptable>() -> Self {
2826
Self {
2927
protected_attributes: D::protected_attributes(),
30-
plaintext_attributes: D::plaintext_attributes(),
3128
}
3229
}
3330
}
@@ -65,8 +62,6 @@ impl SealedTableEntry {
6562

6663
let UnsealSpec {
6764
protected_attributes,
68-
// TODO: Why is this here?
69-
plaintext_attributes,
7065
} = spec;
7166

7267
let mut unprotected_items = Vec::with_capacity(items.len());

src/crypto/sealer.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ pub struct Sealer {
4242
pub(crate) unsealed: Unsealed,
4343
}
4444

45-
struct RecordsWithTerms<'a> {
45+
struct RecordsWithTerms {
4646
num_protected_attributes: usize,
47-
records: Vec<RecordWithTerms<'a>>,
47+
records: Vec<RecordWithTerms>,
4848
}
4949

50-
impl<'a> RecordsWithTerms<'a> {
51-
fn new(records: Vec<RecordWithTerms<'a>>, num_protected_attributes: usize) -> Self {
50+
impl RecordsWithTerms {
51+
fn new(records: Vec<RecordWithTerms>, num_protected_attributes: usize) -> Self {
5252
Self {
5353
num_protected_attributes,
5454
records,
@@ -117,15 +117,13 @@ impl<'a> RecordsWithTerms<'a> {
117117
}
118118
}
119119

120-
struct RecordWithTerms<'a> {
120+
struct RecordWithTerms {
121121
pksk: PrimaryKeyParts,
122122
unsealed: Unsealed,
123123
terms: Vec<Term>,
124-
// FIXME: Don't use a Vec here - too many copies
125-
protected_attributes: Vec<Cow<'a, str>>,
126124
}
127125

128-
impl<'a> RecordWithTerms<'a> {
126+
impl RecordWithTerms {
129127
fn into_parts(
130128
self,
131129
) -> (
@@ -145,7 +143,7 @@ impl Sealer {
145143
protected_attributes: impl AsRef<[Cow<'a, str>]>,
146144
cipher: &Encryption<impl Credentials<Token = ServiceToken>>,
147145
term_length: usize,
148-
) -> Result<RecordsWithTerms<'a>, SealError> {
146+
) -> Result<RecordsWithTerms, SealError> {
149147
let protected_attributes = protected_attributes.as_ref();
150148
let num_protected_attributes = protected_attributes.len();
151149

@@ -211,7 +209,6 @@ impl Sealer {
211209
pksk: PrimaryKeyParts { pk, sk },
212210
unsealed: sealer.unsealed,
213211
terms,
214-
protected_attributes: protected_attributes.to_vec(),
215212
})
216213
})
217214
.try_collect()

0 commit comments

Comments
 (0)