avoid lifetimes in blob reader/writer

This commit is contained in:
Wolfgang Bumiller
2019-08-16 09:19:01 +02:00
committed by Dietmar Maurer
parent 71d08e00b7
commit 9025312aa6
10 changed files with 98 additions and 79 deletions

View File

@ -641,11 +641,11 @@ impl BackupClient {
futures::future::ok(())
.and_then(move |_| {
let blob = if let Some(ref crypt_config) = crypt_config {
let blob = if let Some(crypt_config) = crypt_config {
if sign_only {
DataBlob::create_signed(&data, crypt_config, compress)?
} else {
DataBlob::encode(&data, Some(crypt_config), compress)?
DataBlob::encode(&data, Some(crypt_config.clone()), compress)?
}
} else {
DataBlob::encode(&data, None, compress)?
@ -683,11 +683,7 @@ impl BackupClient {
tokio::io::read_to_end(file, contents)
.map_err(Error::from)
.and_then(move |(_, contents)| {
let blob = if let Some(ref crypt_config) = crypt_config {
DataBlob::encode(&contents, Some(crypt_config), compress)?
} else {
DataBlob::encode(&contents, None, compress)?
};
let blob = DataBlob::encode(&contents, crypt_config, compress)?;
let raw_data = blob.into_inner();
Ok((raw_data, contents.len() as u64))
})