diff --git a/core/embed/rust/src/trace.rs b/core/embed/rust/src/trace.rs index 2147f44899..b6a03bd8d0 100644 --- a/core/embed/rust/src/trace.rs +++ b/core/embed/rust/src/trace.rs @@ -1,5 +1,6 @@ /// Visitor passed into `Trace` types. pub trait Tracer { + fn int(&mut self, i: i64); fn bytes(&mut self, b: &[u8]); fn string(&mut self, s: &str); fn symbol(&mut self, name: &str); @@ -25,6 +26,12 @@ impl Trace for &str { } } +impl Trace for usize { + fn trace(&self, t: &mut dyn Tracer) { + t.int(*self as i64); + } +} + impl Trace for Option where T: Trace, diff --git a/core/embed/rust/src/ui/layout/obj.rs b/core/embed/rust/src/ui/layout/obj.rs index 94638df461..1e9a14929c 100644 --- a/core/embed/rust/src/ui/layout/obj.rs +++ b/core/embed/rust/src/ui/layout/obj.rs @@ -169,6 +169,10 @@ impl LayoutObj { struct CallbackTracer(Obj); impl Tracer for CallbackTracer { + fn int(&mut self, i: i64) { + self.0.call_with_n_args(&[i.try_into().unwrap()]).unwrap(); + } + fn bytes(&mut self, b: &[u8]) { self.0.call_with_n_args(&[b.try_into().unwrap()]).unwrap(); } diff --git a/core/embed/rust/src/ui/model_t1/layout.rs b/core/embed/rust/src/ui/model_t1/layout.rs index 3f28a0070d..1bcec5eff6 100644 --- a/core/embed/rust/src/ui/model_t1/layout.rs +++ b/core/embed/rust/src/ui/model_t1/layout.rs @@ -84,6 +84,10 @@ mod tests { use super::*; impl Tracer for Vec { + fn int(&mut self, i: i64) { + self.string(&i.to_string()); + } + fn bytes(&mut self, b: &[u8]) { self.extend(b) } diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index 5b3dcf8179..507cd9ab5d 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -59,6 +59,10 @@ mod tests { use super::*; impl Tracer for Vec { + fn int(&mut self, i: i64) { + self.string(&i.to_string()); + } + fn bytes(&mut self, b: &[u8]) { self.extend(b) }