rust: change imports to util::bb02_async
What changed, and why it matters
This commit is a routine code cleanup: it changes many Rust source files to import a small async helper module from a shared utility crate (`util::bb02_async`) instead of from the local crate (`crate::bb02_async`). There is no change to program logic, no bug fix, and no security-relevant behavior.
No security action needed; treat as normal refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is a pure refactoring of import paths. bitbox02-rust/src/bb02_async.rs stops re-exporting util::bb02_async::{Task, option, spin, block_on} and instead the callers import those items directly from util::bb02_async. The only functional code change is inside option_no_screensaver, which now calls util::bb02_async::option directly rather than the previously re-exported option. No algorithms, permissions, or data handling change.
Changed components
bitbox02-firmware Rust async helper importsbitbox02-rust/src/bb02_async.rsbitbox02-rust-c/src/workflow.rsInspect captured patch +26 / −30
diff --git a/src/rust/bitbox02-rust-c/src/workflow.rs b/src/rust/bitbox02-rust-c/src/workflow.rs
index ea5df50..ba904b4 100644
--- a/src/rust/bitbox02-rust-c/src/workflow.rs
+++ b/src/rust/bitbox02-rust-c/src/workflow.rs
@@ -24,9 +24,9 @@ extern crate alloc;
use alloc::boxed::Box;
use alloc::string::String;
-use bitbox02_rust::bb02_async::{Task, spin};
use bitbox02_rust::workflow::confirm;
use core::task::Poll;
+use util::bb02_async::{Task, spin};
enum TaskState<'a, O> {
Nothing,
diff --git a/src/rust/bitbox02-rust/src/async_usb.rs b/src/rust/bitbox02-rust/src/async_usb.rs
index e21c62d..ed1f011 100644
--- a/src/rust/bitbox02-rust/src/async_usb.rs
+++ b/src/rust/bitbox02-rust/src/async_usb.rs
@@ -15,11 +15,11 @@
//! This module provides the executor for tasks that are spawned with an API request and deliver a
//! USB response. Terminology: host = computer, device = BitBox02.
-use crate::bb02_async::{Task, option, spin as spin_task};
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::cell::RefCell;
use core::task::Poll;
+use util::bb02_async::{Task, option, spin as spin_task};
type UsbOut = Vec<u8>;
type UsbIn = Vec<u8>;
diff --git a/src/rust/bitbox02-rust/src/bb02_async.rs b/src/rust/bitbox02-rust/src/bb02_async.rs
index 2a602e4..fbaeb01 100644
--- a/src/rust/bitbox02-rust/src/bb02_async.rs
+++ b/src/rust/bitbox02-rust/src/bb02_async.rs
@@ -14,14 +14,10 @@
use core::cell::RefCell;
-#[cfg(feature = "testing")]
-pub use util::bb02_async::block_on;
-pub use util::bb02_async::{Task, option, spin};
-
/// Disables the screensaver while waiting for an option to contain a value. Afterwards, it returns that value
pub async fn option_no_screensaver<O>(opt: &RefCell<Option<O>>) -> O {
bitbox02::screen_saver::screen_saver_disable();
- let result = option(opt).await;
+ let result = util::bb02_async::option(opt).await;
bitbox02::screen_saver::screen_saver_enable();
result
}
diff --git a/src/rust/bitbox02-rust/src/hww.rs b/src/rust/bitbox02-rust/src/hww.rs
index d86a7db..c9f7511 100644
--- a/src/rust/bitbox02-rust/src/hww.rs
+++ b/src/rust/bitbox02-rust/src/hww.rs
@@ -136,10 +136,10 @@ mod tests {
use super::*;
extern crate std;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use bitbox02::testing::mock_memory;
+ use util::bb02_async::block_on;
use prost::Message;
diff --git a/src/rust/bitbox02-rust/src/hww/api/backup.rs b/src/rust/bitbox02-rust/src/hww/api/backup.rs
index b06f498..d4b9954 100644
--- a/src/rust/bitbox02-rust/src/hww/api/backup.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/backup.rs
@@ -162,11 +162,11 @@ pub fn list(hal: &mut impl crate::hal::Hal) -> Result<Response, Error> {
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use alloc::boxed::Box;
use bitbox02::testing::{mock_memory, mock_unlocked, mock_unlocked_using_mnemonic};
+ use util::bb02_async::block_on;
/// Test backup creation on a uninitialized keystore.
#[test]
diff --git a/src/rust/bitbox02-rust/src/hww/api/bitcoin.rs b/src/rust/bitbox02-rust/src/hww/api/bitcoin.rs
index d1035d3..5f80d58 100644
--- a/src/rust/bitbox02-rust/src/hww/api/bitcoin.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/bitcoin.rs
@@ -331,7 +331,6 @@ pub async fn process_api(
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::bip32::parse_xpub;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
@@ -341,6 +340,7 @@ mod tests {
TEST_MNEMONIC, mock_memory, mock_unlocked, mock_unlocked_using_mnemonic,
};
use pb::btc_script_config::multisig::ScriptType as MultisigScriptType;
+ use util::bb02_async::block_on;
use util::bip32::HARDENED;
#[test]
diff --git a/src/rust/bitbox02-rust/src/hww/api/bitcoin/signmsg.rs b/src/rust/bitbox02-rust/src/hww/api/bitcoin/signmsg.rs
index 22da8d0..8995fde 100644
--- a/src/rust/bitbox02-rust/src/hww/api/bitcoin/signmsg.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/bitcoin/signmsg.rs
@@ -140,11 +140,11 @@ pub async fn process(
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use alloc::boxed::Box;
use bitbox02::testing::mock_unlocked;
+ use util::bb02_async::block_on;
use util::bip32::HARDENED;
const MESSAGE: &str = "message";
diff --git a/src/rust/bitbox02-rust/src/hww/api/bitcoin/signtx.rs b/src/rust/bitbox02-rust/src/hww/api/bitcoin/signtx.rs
index c7f8d37..a25f876 100644
--- a/src/rust/bitbox02-rust/src/hww/api/bitcoin/signtx.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/bitcoin/signtx.rs
@@ -1273,13 +1273,13 @@ pub async fn process(
#[cfg(test)]
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::bip32::parse_xpub;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use alloc::boxed::Box;
use bitbox02::testing::{mock_memory, mock_unlocked, mock_unlocked_using_mnemonic};
use pb::btc_payment_request_request::{Memo, memo};
+ use util::bb02_async::block_on;
use util::bip32::HARDENED;
fn extract_next(response: &Response) -> &pb::BtcSignNextResponse {
diff --git a/src/rust/bitbox02-rust/src/hww/api/bitcoin/xpubs.rs b/src/rust/bitbox02-rust/src/hww/api/bitcoin/xpubs.rs
index 4b1e85e..7546ee3 100644
--- a/src/rust/bitbox02-rust/src/hww/api/bitcoin/xpubs.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/bitcoin/xpubs.rs
@@ -68,8 +68,8 @@ pub async fn process_xpubs(request: &pb::BtcXpubsRequest) -> Result<Response, Er
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use bitbox02::testing::{mock_memory, mock_unlocked, mock_unlocked_using_mnemonic};
+ use util::bb02_async::block_on;
use util::bip32::HARDENED;
#[test]
diff --git a/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs b/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs
index 59acb9c..dcee051 100644
--- a/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs
@@ -230,8 +230,8 @@ pub async fn process_api(
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use bitbox02::testing::mock_memory;
+ use util::bb02_async::block_on;
#[test]
fn test_chunk_streaming() {
diff --git a/src/rust/bitbox02-rust/src/hww/api/cardano/address.rs b/src/rust/bitbox02-rust/src/hww/api/cardano/address.rs
index 408e287..130af4e 100644
--- a/src/rust/bitbox02-rust/src/hww/api/cardano/address.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/cardano/address.rs
@@ -402,11 +402,11 @@ pub async fn process(
#[cfg(test)]
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use alloc::boxed::Box;
use bitbox02::testing::mock_unlocked;
+ use util::bb02_async::block_on;
use util::bip32::HARDENED;
#[test]
diff --git a/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction.rs b/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction.rs
index 2b5c571..b3a5042 100644
--- a/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction.rs
@@ -330,11 +330,11 @@ pub async fn process(
#[cfg(test)]
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use alloc::boxed::Box;
use bitbox02::testing::mock_unlocked;
+ use util::bb02_async::block_on;
use util::bip32::HARDENED;
use pb::cardano_sign_transaction_request::{Certificate, certificate, certificate::Cert};
diff --git a/src/rust/bitbox02-rust/src/hww/api/electrum.rs b/src/rust/bitbox02-rust/src/hww/api/electrum.rs
index 1d54b55..640f158 100644
--- a/src/rust/bitbox02-rust/src/hww/api/electrum.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/electrum.rs
@@ -52,9 +52,9 @@ pub async fn process(
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use alloc::boxed::Box;
use bitbox02::testing::mock_unlocked;
+ use util::bb02_async::block_on;
#[test]
pub fn test_process() {
diff --git a/src/rust/bitbox02-rust/src/hww/api/ethereum/pubrequest.rs b/src/rust/bitbox02-rust/src/hww/api/ethereum/pubrequest.rs
index 666cff8..53f827f 100644
--- a/src/rust/bitbox02-rust/src/hww/api/ethereum/pubrequest.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/ethereum/pubrequest.rs
@@ -101,11 +101,11 @@ pub async fn process(
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use alloc::boxed::Box;
use bitbox02::testing::mock_unlocked;
+ use util::bb02_async::block_on;
use util::bip32::HARDENED;
#[test]
diff --git a/src/rust/bitbox02-rust/src/hww/api/ethereum/sign.rs b/src/rust/bitbox02-rust/src/hww/api/ethereum/sign.rs
index 6684279..9f0f64a 100644
--- a/src/rust/bitbox02-rust/src/hww/api/ethereum/sign.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/ethereum/sign.rs
@@ -440,11 +440,11 @@ pub async fn process(
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use alloc::boxed::Box;
use bitbox02::testing::mock_unlocked;
+ use util::bb02_async::block_on;
use util::bip32::HARDENED;
#[test]
diff --git a/src/rust/bitbox02-rust/src/hww/api/ethereum/sign_typed_msg.rs b/src/rust/bitbox02-rust/src/hww/api/ethereum/sign_typed_msg.rs
index 4c1772c..2eb81f8 100644
--- a/src/rust/bitbox02-rust/src/hww/api/ethereum/sign_typed_msg.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/ethereum/sign_typed_msg.rs
@@ -602,10 +602,10 @@ pub async fn process(
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use bitbox02::testing::mock_unlocked;
+ use util::bb02_async::block_on;
use util::bip32::HARDENED;
use alloc::boxed::Box;
diff --git a/src/rust/bitbox02-rust/src/hww/api/ethereum/signmsg.rs b/src/rust/bitbox02-rust/src/hww/api/ethereum/signmsg.rs
index 6f861f9..48ba348 100644
--- a/src/rust/bitbox02-rust/src/hww/api/ethereum/signmsg.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/ethereum/signmsg.rs
@@ -107,11 +107,11 @@ pub async fn process(
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use alloc::boxed::Box;
use bitbox02::testing::mock_unlocked;
+ use util::bb02_async::block_on;
use util::bip32::HARDENED;
const KEYPATH: &[u32] = &[44 + HARDENED, 60 + HARDENED, 0 + HARDENED, 0, 0];
diff --git a/src/rust/bitbox02-rust/src/hww/api/reset.rs b/src/rust/bitbox02-rust/src/hww/api/reset.rs
index 0aa5950..d70aaf1 100644
--- a/src/rust/bitbox02-rust/src/hww/api/reset.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/reset.rs
@@ -39,11 +39,11 @@ pub async fn process(hal: &mut impl crate::hal::Hal) -> Result<Response, Error>
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use alloc::boxed::Box;
use bitbox02::testing::mock_memory;
+ use util::bb02_async::block_on;
#[test]
pub fn test_reset() {
diff --git a/src/rust/bitbox02-rust/src/hww/api/restore.rs b/src/rust/bitbox02-rust/src/hww/api/restore.rs
index 83bf95d..d3c706b 100644
--- a/src/rust/bitbox02-rust/src/hww/api/restore.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/restore.rs
@@ -166,10 +166,10 @@ pub async fn from_mnemonic(
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use bitbox02::testing::mock_memory;
use bitbox02::{keystore, memory};
+ use util::bb02_async::block_on;
use alloc::boxed::Box;
diff --git a/src/rust/bitbox02-rust/src/hww/api/sdcard.rs b/src/rust/bitbox02-rust/src/hww/api/sdcard.rs
index 579e7d9..65d471b 100644
--- a/src/rust/bitbox02-rust/src/hww/api/sdcard.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/sdcard.rs
@@ -41,9 +41,9 @@ pub async fn process(
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use alloc::boxed::Box;
+ use util::bb02_async::block_on;
#[test]
pub fn test_reset() {
diff --git a/src/rust/bitbox02-rust/src/hww/api/set_device_name.rs b/src/rust/bitbox02-rust/src/hww/api/set_device_name.rs
index 58277de..e4965c5 100644
--- a/src/rust/bitbox02-rust/src/hww/api/set_device_name.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/set_device_name.rs
@@ -46,11 +46,11 @@ pub async fn process(
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use alloc::boxed::Box;
use bitbox02::testing::mock_memory;
+ use util::bb02_async::block_on;
#[test]
pub fn test_set_device_name() {
diff --git a/src/rust/bitbox02-rust/src/hww/api/set_mnemonic_passphrase_enabled.rs b/src/rust/bitbox02-rust/src/hww/api/set_mnemonic_passphrase_enabled.rs
index d0eb748..97b2392 100644
--- a/src/rust/bitbox02-rust/src/hww/api/set_mnemonic_passphrase_enabled.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/set_mnemonic_passphrase_enabled.rs
@@ -44,11 +44,11 @@ pub async fn process(
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use alloc::boxed::Box;
use bitbox02::testing::mock_memory;
+ use util::bb02_async::block_on;
#[test]
pub fn test_mnemonic_passphrase_enabled() {
diff --git a/src/rust/bitbox02-rust/src/hww/api/set_password.rs b/src/rust/bitbox02-rust/src/hww/api/set_password.rs
index b040d7d..49465f4 100644
--- a/src/rust/bitbox02-rust/src/hww/api/set_password.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/set_password.rs
@@ -48,9 +48,9 @@ pub async fn process(
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use bitbox02::testing::mock_memory;
+ use util::bb02_async::block_on;
use alloc::boxed::Box;
diff --git a/src/rust/bitbox02-rust/src/hww/api/system.rs b/src/rust/bitbox02-rust/src/hww/api/system.rs
index a901242..6666339 100644
--- a/src/rust/bitbox02-rust/src/hww/api/system.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/system.rs
@@ -46,10 +46,10 @@ mod tests {
extern crate std;
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
use alloc::boxed::Box;
+ use util::bb02_async::block_on;
#[test]
pub fn test_reboot_to_bootloader() {
diff --git a/src/rust/bitbox02-rust/src/workflow/pairing.rs b/src/rust/bitbox02-rust/src/workflow/pairing.rs
index f2b4d99..0a67e3e 100644
--- a/src/rust/bitbox02-rust/src/workflow/pairing.rs
+++ b/src/rust/bitbox02-rust/src/workflow/pairing.rs
@@ -48,9 +48,9 @@ pub async fn confirm(hal: &mut impl crate::hal::Hal, hash: &[u8; 32]) -> Result<
mod tests {
use super::*;
- use crate::bb02_async::block_on;
use crate::hal::testing::TestingHal;
use crate::workflow::testing::Screen;
+ use util::bb02_async::block_on;
use alloc::boxed::Box;
diff --git a/src/rust/bitbox02-rust/src/workflow/trinary_input_string.rs b/src/rust/bitbox02-rust/src/workflow/trinary_input_string.rs
index ffbcc4c..ddc9a9d 100644
--- a/src/rust/bitbox02-rust/src/workflow/trinary_input_string.rs
+++ b/src/rust/bitbox02-rust/src/workflow/trinary_input_string.rs
@@ -15,8 +15,8 @@
pub use super::cancel::{Error, cancel, set_result};
pub use bitbox02::ui::TrinaryInputStringParams as Params;
-use crate::bb02_async::option;
use core::cell::RefCell;
+use util::bb02_async::option;
use alloc::boxed::Box;
use alloc::string::String;
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.