/// Converts a `pwbox` into serializable form.
Converts a `pwbox` into serializable form.
Converts a ` pwbox ` into serializable form .
pub fn erase<K, C>(&self, pwbox: &PwBox<K, C>) -> Result<ErasedPwBox, EraseError>
    where
        K: DeriveKey + Serialize,
        C: Cipher,
    {
        let kdf = match self.lookup_kdf::<K>() {
            Some(kdf) => kdf,
            None => return Err(EraseError::NoKdf),
        };
        let cipher = match self.lookup_cipher::<C>() {
            Some(cipher) => cipher,
            None => return Err(EraseError::NoCipher),
        };
        let kdf_params = match serde_json::to_value(&pwbox.inner.kdf) {
            Ok(params) => params,
            Err(e) => return Err(EraseError::SerializeKdf(e)),
        };
        let pwbox = &pwbox.inner;
        Ok(ErasedPwBox {
            encrypted: pwbox.encrypted.clone(),
            kdf: kdf.to_owned(),
            kdf_params: KdfParams {
                salt: pwbox.salt.clone(),
                inner: kdf_params,
            },
            cipher: cipher.to_owned(),
            cipher_params: CipherParams {
                iv: pwbox.nonce.clone(),
            },
        })
    }
pub fn erase < K , C > ( & self , pwbox : & PwBox < K , C > ) -> Result < ErasedPwBox , EraseError > where K : DeriveKey + Serialize , C : Cipher , { let kdf = match self . lookup_kdf :: < K > ( ) { Some ( kdf ) => kdf , None => return Err ( EraseError :: NoKdf ) , } ; let cipher = match self . lookup_cipher :: < C > ( ) { Some ( cipher ) => cipher , None => return Err ( EraseError :: NoCipher ) , } ; let kdf_params = match serde_json :: to_value ( & pwbox . inner . kdf ) { Ok ( params ) => params , Err ( e ) => return Err ( EraseError :: SerializeKdf ( e ) ) , } ; let pwbox = & pwbox . inner ; Ok ( ErasedPwBox { encrypted : pwbox . encrypted . clone ( ) , kdf : kdf . to_owned ( ) , kdf_params : KdfParams { salt : pwbox . salt . clone ( ) , inner : kdf_params , } , cipher : cipher . to_owned ( ) , cipher_params : CipherParams { iv : pwbox . nonce . clone ( ) , } , } ) }
Converts a `pwbox` into serializable form.
Converts a ` pwbox ` into serializable form .
&self
pwbox
&PwBox<K, C>