diff --git a/src/machine.rs b/src/machine.rs index 8a30d6d29..f9db4ca4e 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -963,29 +963,6 @@ impl OlmMachine { })) } - /// Shared helper for `import_exported_room_keys` and `import_room_keys`. - /// - /// Wraps the progress listener in a Rust closure and runs - /// `Store::import_exported_room_keys` - /// - /// Items inside `exported_room_keys` are going to be deleted on the JS part - /// after the function returns. Be careful to not used `exported_room_keys` - /// after that. - async fn import_exported_room_keys_helper( - inner: &matrix_sdk_crypto::OlmMachine, - exported_room_keys: Vec, - progress_listener: Function, - ) -> Result { - inner - .store() - .import_exported_room_keys(exported_room_keys, |progress, total| { - progress_listener - .call2(&JsValue::NULL, &JsValue::from(progress), &JsValue::from(total)) - .expect("Progress listener passed to `importExportedRoomKeys` failed"); - }) - .await - } - /// Import the given room keys into our store. /// /// # Arguments @@ -1410,6 +1387,31 @@ impl OlmMachine { pub fn close(self) {} } +impl OlmMachine { + /// Shared helper for `import_exported_room_keys` and `import_room_keys`. + /// + /// Wraps the progress listener in a Rust closure and runs + /// `Store::import_exported_room_keys` + /// + /// Items inside `exported_room_keys` will be invalidated by this method. Be + /// careful to not used `ExportedRoomKey`s after this method has been + /// called. + async fn import_exported_room_keys_helper( + inner: &matrix_sdk_crypto::OlmMachine, + exported_room_keys: Vec, + progress_listener: Function, + ) -> Result { + inner + .store() + .import_exported_room_keys(exported_room_keys, |progress, total| { + progress_listener + .call2(&JsValue::NULL, &JsValue::from(progress), &JsValue::from(total)) + .expect("Progress listener passed to `importExportedRoomKeys` failed"); + }) + .await + } +} + // helper for register_room_key_received_callback: wraps the key info // into our own RoomKeyInfo struct, and passes it into the javascript // function