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

@ -1,5 +1,6 @@
use failure::*;
use std::convert::TryInto;
use std::sync::Arc;
use proxmox::tools::io::{ReadExt, WriteExt};
@ -69,7 +70,7 @@ impl DataBlob {
/// Create a DataBlob, optionally compressed and/or encrypted
pub fn encode(
data: &[u8],
config: Option<&CryptConfig>,
config: Option<Arc<CryptConfig>>,
compress: bool,
) -> Result<Self, Error> {
@ -158,7 +159,7 @@ impl DataBlob {
}
/// Decode blob data
pub fn decode(self, config: Option<&CryptConfig>) -> Result<Vec<u8>, Error> {
pub fn decode(self, config: Option<Arc<CryptConfig>>) -> Result<Vec<u8>, Error> {
let magic = self.magic();
@ -215,7 +216,7 @@ impl DataBlob {
/// Create a signed DataBlob, optionally compressed
pub fn create_signed(
data: &[u8],
config: &CryptConfig,
config: Arc<CryptConfig>,
compress: bool,
) -> Result<Self, Error> {