mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-15 19:08:07 +00:00
style(core/rust): fix linter complaints
This commit is contained in:
parent
31958b7fb8
commit
ac5a5147e9
@ -10,7 +10,7 @@ use num_traits::{FromPrimitive, ToPrimitive};
|
|||||||
#[cfg(feature = "button")]
|
#[cfg(feature = "button")]
|
||||||
use crate::ui::event::ButtonEvent;
|
use crate::ui::event::ButtonEvent;
|
||||||
#[cfg(feature = "new_rendering")]
|
#[cfg(feature = "new_rendering")]
|
||||||
use crate::ui::{display::Color, shape::render_on_display, shape::Renderer};
|
use crate::ui::{display::Color, shape::render_on_display};
|
||||||
#[cfg(feature = "touch")]
|
#[cfg(feature = "touch")]
|
||||||
use crate::ui::{event::TouchEvent, geometry::Direction};
|
use crate::ui::{event::TouchEvent, geometry::Direction};
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -31,9 +31,8 @@ use crate::{
|
|||||||
ui::{
|
ui::{
|
||||||
button_request::ButtonRequest,
|
button_request::ButtonRequest,
|
||||||
component::{base::{AttachType, TimerToken}, Component, Event, EventCtx, Never},
|
component::{base::{AttachType, TimerToken}, Component, Event, EventCtx, Never},
|
||||||
constant, display,
|
display,
|
||||||
event::USBEvent,
|
event::USBEvent,
|
||||||
geometry::Rect,
|
|
||||||
ui_features::ModelUI,
|
ui_features::ModelUI,
|
||||||
UIFeaturesCommon,
|
UIFeaturesCommon,
|
||||||
},
|
},
|
||||||
@ -88,52 +87,7 @@ pub trait ComponentMsgObj: Component {
|
|||||||
fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error>;
|
fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Object-safe interface between trait `Component` and MicroPython world. It
|
pub trait ComponentMaybeTrace: Component + ComponentMsgObj + MaybeTrace {}
|
||||||
/// converts the result of `Component::event` into `Obj` via the
|
|
||||||
/// `ComponentMsgObj` trait, in order to easily return the value to Python. It
|
|
||||||
/// also optionally implies `Trace` for UI debugging.
|
|
||||||
/// Note: we need to use an object-safe trait in order to store it in a `Gc<dyn
|
|
||||||
/// T>` field. `Component` itself is not object-safe because of `Component::Msg`
|
|
||||||
/// associated type.
|
|
||||||
// pub trait ObjComponent: MaybeTrace {
|
|
||||||
// fn obj_place(&mut self, bounds: Rect) -> Rect;
|
|
||||||
// fn obj_event(&mut self, ctx: &mut EventCtx, event: Event) -> Result<Obj,
|
|
||||||
// Error>; fn obj_paint(&mut self);
|
|
||||||
// fn obj_bounds(&self, _sink: &mut dyn FnMut(Rect)) {}
|
|
||||||
// }
|
|
||||||
|
|
||||||
// impl<T> ObjComponent for T
|
|
||||||
// where
|
|
||||||
// T: Component + ComponentMsgObj + MaybeTrace,
|
|
||||||
// {
|
|
||||||
// fn obj_place(&mut self, bounds: Rect) -> Rect {
|
|
||||||
// self.place(bounds)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn obj_event(&mut self, ctx: &mut EventCtx, event: Event) -> Result<Obj,
|
|
||||||
// Error> { if let Some(msg) = self.event(ctx, event) {
|
|
||||||
// self.msg_try_into_obj(msg)
|
|
||||||
// } else {
|
|
||||||
// Ok(Obj::const_none())
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn obj_paint(&mut self) {
|
|
||||||
// #[cfg(not(feature = "new_rendering"))]
|
|
||||||
// {
|
|
||||||
// self.paint();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[cfg(feature = "new_rendering")]
|
|
||||||
// {
|
|
||||||
// render_on_display(None, Some(Color::black()), |target| {
|
|
||||||
// self.render(target);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
trait ComponentMaybeTrace: Component + ComponentMsgObj + MaybeTrace {}
|
|
||||||
impl<T> ComponentMaybeTrace for T where T: Component + ComponentMsgObj + MaybeTrace {}
|
impl<T> ComponentMaybeTrace for T where T: Component + ComponentMsgObj + MaybeTrace {}
|
||||||
|
|
||||||
struct RootComponent<T, M>
|
struct RootComponent<T, M>
|
||||||
@ -205,7 +159,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait LayoutMaybeTrace: Layout<Result<Obj, Error>> + MaybeTrace {}
|
pub trait LayoutMaybeTrace: Layout<Result<Obj, Error>> + MaybeTrace {}
|
||||||
impl<T> LayoutMaybeTrace for T where T: Layout<Result<Obj, Error>> + MaybeTrace {}
|
impl<T> LayoutMaybeTrace for T where T: Layout<Result<Obj, Error>> + MaybeTrace {}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
use crate::micropython::{
|
use crate::micropython::{macros::obj_type, qstr::Qstr, simple_type::SimpleTypeObj, typ::Type};
|
||||||
macros::{obj_dict, obj_map, obj_type},
|
|
||||||
qstr::Qstr,
|
|
||||||
simple_type::SimpleTypeObj,
|
|
||||||
typ::Type,
|
|
||||||
};
|
|
||||||
|
|
||||||
static CONFIRMED_TYPE: Type = obj_type! { name: Qstr::MP_QSTR_CONFIRMED, };
|
static CONFIRMED_TYPE: Type = obj_type! { name: Qstr::MP_QSTR_CONFIRMED, };
|
||||||
static CANCELLED_TYPE: Type = obj_type! { name: Qstr::MP_QSTR_CANCELLED, };
|
static CANCELLED_TYPE: Type = obj_type! { name: Qstr::MP_QSTR_CANCELLED, };
|
||||||
|
@ -365,7 +365,7 @@ impl HideLabelAnimation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Timer(token) if self.timer.expire(event) && !animation_disabled() => {
|
Event::Timer(_) if self.timer.expire(event) && !animation_disabled() => {
|
||||||
self.stopwatch.start();
|
self.stopwatch.start();
|
||||||
ctx.request_anim_frame();
|
ctx.request_anim_frame();
|
||||||
self.animating = true;
|
self.animating = true;
|
||||||
@ -524,7 +524,7 @@ impl Homescreen {
|
|||||||
self.loader.start_shrinking(ctx, now);
|
self.loader.start_shrinking(ctx, now);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Timer(token) if self.delay.expire(event) => {
|
Event::Timer(_) if self.delay.expire(event) => {
|
||||||
self.loader.start_growing(ctx, Instant::now());
|
self.loader.start_growing(ctx, Instant::now());
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -36,7 +36,6 @@ use super::theme::BLACK;
|
|||||||
|
|
||||||
#[cfg(feature = "new_rendering")]
|
#[cfg(feature = "new_rendering")]
|
||||||
use crate::ui::{
|
use crate::ui::{
|
||||||
constant,
|
|
||||||
display::toif::Toif,
|
display::toif::Toif,
|
||||||
geometry::{Alignment, Alignment2D, Offset},
|
geometry::{Alignment, Alignment2D, Offset},
|
||||||
shape,
|
shape,
|
||||||
|
Loading…
Reference in New Issue
Block a user