From 11d548acaa24225a9f3f147ba20f77bc0a2b2929 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 8 Jun 2026 09:28:27 +0200 Subject: [PATCH 1/2] virt: Simplify UserIterface::set_inner signature In practice, the impl Into only makes things more complicated because type inference does not work and users need to add type annotations: https://github.com/trussed-dev/fido-authenticator/blob/4bd3629b6695c10152796f9e9d5d5f9583b43a6a/tests/virt/mod.rs#L327 So we can also just pass the box directly. --- src/virt/ui.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/virt/ui.rs b/src/virt/ui.rs index fd51f774bb1..1e630aa58ee 100644 --- a/src/virt/ui.rs +++ b/src/virt/ui.rs @@ -14,8 +14,8 @@ impl UserInterface { } } - pub fn set_inner(&mut self, inner: impl Into>) { - self.inner = Some(inner.into()); + pub fn set_inner(&mut self, inner: Box) { + self.inner = Some(inner); } pub fn take_inner(&mut self) -> Option> { From 72e8e5ece12e07b23ef960ced0938e17bf877ed1 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 8 Jun 2026 09:32:22 +0200 Subject: [PATCH 2/2] virt: Make default user presence level configurable This makes it easier to test different user presence levels without having to implement the full UserInterface trait. --- src/virt/ui.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/virt/ui.rs b/src/virt/ui.rs index 1e630aa58ee..954ebda18ed 100644 --- a/src/virt/ui.rs +++ b/src/virt/ui.rs @@ -3,6 +3,7 @@ use std::time::{Duration, Instant}; pub struct UserInterface { start_time: Instant, + user_presence_level: Level, inner: Option>, } @@ -10,10 +11,15 @@ impl UserInterface { pub fn new() -> Self { Self { start_time: Instant::now(), + user_presence_level: Level::Normal, inner: None, } } + pub fn set_user_presence_level(&mut self, level: Level) { + self.user_presence_level = level; + } + pub fn set_inner(&mut self, inner: Box) { self.inner = Some(inner); } @@ -34,7 +40,7 @@ impl platform::UserInterface for UserInterface { self.inner .as_mut() .map(|inner| inner.check_user_presence()) - .unwrap_or(Level::Normal) + .unwrap_or(self.user_presence_level) } fn set_status(&mut self, status: Status) {