Skip to content

Commit cc0a2ad

Browse files
adamreeverok
authored andcommitted
Tidy up some duplication
1 parent cecf752 commit cc0a2ad

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

parquet/src/encryption/encrypt.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,26 +200,19 @@ impl FileEncryptor {
200200
}
201201
}
202202

203-
/// Encrypt a Thrift serializable object
203+
/// Write an encrypted Thrift serializable object
204204
pub(crate) fn encrypt_object<T: TSerializable, W: Write>(
205205
object: &T,
206206
encryptor: &mut Box<dyn BlockEncryptor>,
207207
sink: &mut W,
208208
module_aad: &[u8],
209209
) -> Result<()> {
210-
let mut buffer: Vec<u8> = vec![];
211-
{
212-
let mut unencrypted_protocol = TCompactOutputProtocol::new(&mut buffer);
213-
object.write_to_out_protocol(&mut unencrypted_protocol)?;
214-
}
215-
216-
let encrypted_buffer = encryptor.encrypt(buffer.as_ref(), module_aad)?;
217-
210+
let encrypted_buffer = encrypt_object_to_vec(object, encryptor, module_aad)?;
218211
sink.write_all(&encrypted_buffer)?;
219212
Ok(())
220213
}
221214

222-
/// Encrypt a Thrift serializable object
215+
/// Encrypt a Thrift serializable object to a byte vector
223216
pub(crate) fn encrypt_object_to_vec<T: TSerializable>(
224217
object: &T,
225218
encryptor: &mut Box<dyn BlockEncryptor>,

0 commit comments

Comments
 (0)