Skip to content

Add enum for distinguishing between pickling with key and empty key

Johannes Hayeß requested to merge pickling_mode into master

This change will improve code readability, as now it has to be made clear that one is choosing an encryption mode and not just putting some random data into some function.

Before

use olm_rs::account::OlmAccount;

let identity_keys;
let olm_account = OlmAccount::new();
identity_keys = olm_account.identity_keys();
let pickled = olm_account.pickle(&[]);
let olm_account_2 = OlmAccount::unpickle(pickled, &[]).unwrap();
let identity_keys_2 = olm_account_2.identity_keys();

assert_eq!(identity_keys, identity_keys_2);

After

use olm_rs::account::OlmAccount;
use olm_rs::PicklingMode;

let identity_keys;
let olm_account = OlmAccount::new();
identity_keys = olm_account.identity_keys();
let pickled = olm_account.pickle(PicklingMode::Unencrypted);
let olm_account_2 = OlmAccount::unpickle(pickled, PicklingMode::Unencrypted).unwrap();
let identity_keys_2 = olm_account_2.identity_keys();

assert_eq!(identity_keys, identity_keys_2);

Closes #29 (closed)

Edited by Johannes Hayeß

Merge request reports