mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-17 19:00:58 +00:00
refactor(core): add ufmt, bump heapless from 0.7.6 - 0.8.0
[no changelog]
This commit is contained in:
parent
ffccf849eb
commit
285b22e53e
56
core/embed/rust/Cargo.lock
generated
56
core/embed/rust/Cargo.lock
generated
@ -95,22 +95,22 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hash32"
|
name = "hash32"
|
||||||
version = "0.2.1"
|
version = "0.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
|
checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heapless"
|
name = "heapless"
|
||||||
version = "0.7.6"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "14db22a3fec113074342010bb85a75ba17789244649af8a3178594e0dc97c381"
|
checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hash32",
|
"hash32",
|
||||||
"spin",
|
|
||||||
"stable_deref_trait",
|
"stable_deref_trait",
|
||||||
|
"ufmt-write",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -147,15 +147,6 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lock_api"
|
|
||||||
version = "0.4.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"
|
|
||||||
dependencies = [
|
|
||||||
"scopeguard",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.4.1"
|
version = "2.4.1"
|
||||||
@ -253,12 +244,6 @@ version = "1.0.13"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
|
checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "scopeguard"
|
|
||||||
version = "1.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.160"
|
version = "1.0.160"
|
||||||
@ -287,9 +272,6 @@ name = "spin"
|
|||||||
version = "0.9.8"
|
version = "0.9.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||||
dependencies = [
|
|
||||||
"lock_api",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stable_deref_trait"
|
name = "stable_deref_trait"
|
||||||
@ -328,9 +310,37 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"spin",
|
"spin",
|
||||||
"trezor-tjpgdec",
|
"trezor-tjpgdec",
|
||||||
|
"ufmt",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ufmt"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1a64846ec02b57e9108d6469d98d1648782ad6bb150a95a9baac26900bbeab9d"
|
||||||
|
dependencies = [
|
||||||
|
"ufmt-macros",
|
||||||
|
"ufmt-write",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ufmt-macros"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d337d3be617449165cb4633c8dece429afd83f84051024079f97ad32a9663716"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ufmt-write"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
@ -79,6 +79,7 @@ debug = 2
|
|||||||
qrcodegen = { version = "1.8.0", path = "../../vendor/QR-Code-generator/rust-no-heap" }
|
qrcodegen = { version = "1.8.0", path = "../../vendor/QR-Code-generator/rust-no-heap" }
|
||||||
spin = { version = "0.9.8", features = ["rwlock"], default-features = false }
|
spin = { version = "0.9.8", features = ["rwlock"], default-features = false }
|
||||||
trezor-tjpgdec = { version = "0.1.0", path = "../../../rust/trezor-tjpgdec" }
|
trezor-tjpgdec = { version = "0.1.0", path = "../../../rust/trezor-tjpgdec" }
|
||||||
|
ufmt = "0.2.0"
|
||||||
zeroize = { version = "1.7.0", default-features = false, optional = true }
|
zeroize = { version = "1.7.0", default-features = false, optional = true }
|
||||||
|
|
||||||
# Runtime dependencies
|
# Runtime dependencies
|
||||||
@ -87,7 +88,8 @@ zeroize = { version = "1.7.0", default-features = false, optional = true }
|
|||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
|
||||||
[dependencies.heapless]
|
[dependencies.heapless]
|
||||||
version = "0.7.3"
|
version = "0.8.0"
|
||||||
|
features = ["ufmt"]
|
||||||
default_features = false
|
default_features = false
|
||||||
|
|
||||||
[dependencies.num-traits]
|
[dependencies.num-traits]
|
||||||
|
@ -20,6 +20,6 @@ macro_rules! build_string {
|
|||||||
#[allow(unused_macros)] // not used in TT UI
|
#[allow(unused_macros)] // not used in TT UI
|
||||||
macro_rules! inttostr {
|
macro_rules! inttostr {
|
||||||
($int:expr) => {{
|
($int:expr) => {{
|
||||||
heapless::String::<10>::from($int).as_str()
|
unwrap!(heapless::String::<10>::try_from($int)).as_str()
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ pub struct ChoiceItem {
|
|||||||
impl ChoiceItem {
|
impl ChoiceItem {
|
||||||
pub fn new<U: AsRef<str>>(text: U, btn_layout: ButtonLayout) -> Self {
|
pub fn new<U: AsRef<str>>(text: U, btn_layout: ButtonLayout) -> Self {
|
||||||
Self {
|
Self {
|
||||||
text: String::from(text.as_ref()),
|
text: unwrap!(String::try_from(text.as_ref())),
|
||||||
icon: None,
|
icon: None,
|
||||||
btn_layout,
|
btn_layout,
|
||||||
font: theme::FONT_CHOICE_ITEMS,
|
font: theme::FONT_CHOICE_ITEMS,
|
||||||
|
@ -30,7 +30,7 @@ impl ChoiceFactory for ChoiceFactoryNumberInput {
|
|||||||
|
|
||||||
fn get(&self, choice_index: usize) -> (Self::Item, Self::Action) {
|
fn get(&self, choice_index: usize) -> (Self::Item, Self::Action) {
|
||||||
let num = self.min + choice_index as u32;
|
let num = self.min + choice_index as u32;
|
||||||
let text: String<10> = String::from(num);
|
let text: String<10> = unwrap!(String::try_from(num));
|
||||||
let mut choice_item = ChoiceItem::new(
|
let mut choice_item = ChoiceItem::new(
|
||||||
text,
|
text,
|
||||||
ButtonLayout::arrow_armed_arrow(TR::buttons__select.into()),
|
ButtonLayout::arrow_armed_arrow(TR::buttons__select.into()),
|
||||||
|
@ -292,9 +292,9 @@ impl PassphraseEntry {
|
|||||||
|
|
||||||
fn update_passphrase_dots(&mut self, ctx: &mut EventCtx) {
|
fn update_passphrase_dots(&mut self, ctx: &mut EventCtx) {
|
||||||
let text_to_show = if self.show_plain_passphrase {
|
let text_to_show = if self.show_plain_passphrase {
|
||||||
String::from(self.passphrase())
|
unwrap!(String::try_from(self.passphrase()))
|
||||||
} else if self.is_empty() {
|
} else if self.is_empty() {
|
||||||
String::from("")
|
unwrap!(String::try_from(""))
|
||||||
} else {
|
} else {
|
||||||
// Showing asterisks and possibly the last digit.
|
// Showing asterisks and possibly the last digit.
|
||||||
let mut dots: String<MAX_PASSPHRASE_LENGTH> = String::new();
|
let mut dots: String<MAX_PASSPHRASE_LENGTH> = String::new();
|
||||||
|
@ -155,14 +155,14 @@ where
|
|||||||
let (showing_real_prompt, header_line_content, pin_line_content) = if show_subprompt {
|
let (showing_real_prompt, header_line_content, pin_line_content) = if show_subprompt {
|
||||||
(
|
(
|
||||||
false,
|
false,
|
||||||
TR::pin__title_wrong_pin.map_translated(|t| String::from(t)),
|
TR::pin__title_wrong_pin.map_translated(|t| unwrap!(String::try_from(t))),
|
||||||
String::from(subprompt.as_ref()),
|
unwrap!(String::try_from(subprompt.as_ref())),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
(
|
(
|
||||||
true,
|
true,
|
||||||
String::from(prompt.as_ref()),
|
unwrap!(String::try_from(prompt.as_ref())),
|
||||||
String::from(EMPTY_PIN_STR),
|
unwrap!(String::try_from(EMPTY_PIN_STR)),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -204,11 +204,11 @@ where
|
|||||||
let pin_line_text = if self.is_empty() && !self.subprompt.as_ref().is_empty() {
|
let pin_line_text = if self.is_empty() && !self.subprompt.as_ref().is_empty() {
|
||||||
// Showing the subprompt in NORMAL font
|
// Showing the subprompt in NORMAL font
|
||||||
used_font = Font::NORMAL;
|
used_font = Font::NORMAL;
|
||||||
String::from(self.subprompt.as_ref())
|
unwrap!(String::try_from(self.subprompt.as_ref()))
|
||||||
} else if self.is_empty() {
|
} else if self.is_empty() {
|
||||||
String::from(EMPTY_PIN_STR)
|
unwrap!(String::try_from(EMPTY_PIN_STR))
|
||||||
} else if self.show_real_pin {
|
} else if self.show_real_pin {
|
||||||
String::from(self.pin())
|
unwrap!(String::try_from(self.pin()))
|
||||||
} else {
|
} else {
|
||||||
// Showing asterisks and possibly the last digit.
|
// Showing asterisks and possibly the last digit.
|
||||||
let mut dots: String<MAX_PIN_LENGTH> = String::new();
|
let mut dots: String<MAX_PIN_LENGTH> = String::new();
|
||||||
@ -234,7 +234,7 @@ where
|
|||||||
/// Showing the real prompt instead of WRONG PIN
|
/// Showing the real prompt instead of WRONG PIN
|
||||||
fn show_prompt(&mut self, ctx: &mut EventCtx) {
|
fn show_prompt(&mut self, ctx: &mut EventCtx) {
|
||||||
self.header_line.mutate(ctx, |ctx, header_line| {
|
self.header_line.mutate(ctx, |ctx, header_line| {
|
||||||
header_line.update_text(String::from(self.prompt.as_ref()));
|
header_line.update_text(unwrap!(String::try_from(self.prompt.as_ref())));
|
||||||
header_line.request_complete_repaint(ctx);
|
header_line.request_complete_repaint(ctx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,9 @@ impl WordlistEntry {
|
|||||||
.with_incomplete(true)
|
.with_incomplete(true)
|
||||||
.with_carousel(true)
|
.with_carousel(true)
|
||||||
.with_initial_page_counter(get_random_position(choices_count)),
|
.with_initial_page_counter(get_random_position(choices_count)),
|
||||||
chosen_letters: Child::new(ChangingTextLine::center_mono(String::from(PROMPT))),
|
chosen_letters: Child::new(ChangingTextLine::center_mono(unwrap!(String::try_from(
|
||||||
|
PROMPT
|
||||||
|
)))),
|
||||||
textbox: TextBox::empty(),
|
textbox: TextBox::empty(),
|
||||||
offer_words: false,
|
offer_words: false,
|
||||||
wordlist_type,
|
wordlist_type,
|
||||||
@ -193,8 +195,10 @@ impl WordlistEntry {
|
|||||||
choice_page: ChoicePage::new(choices)
|
choice_page: ChoicePage::new(choices)
|
||||||
.with_incomplete(true)
|
.with_incomplete(true)
|
||||||
.with_initial_page_counter(1),
|
.with_initial_page_counter(1),
|
||||||
chosen_letters: Child::new(ChangingTextLine::center_mono(String::from(word))),
|
chosen_letters: Child::new(ChangingTextLine::center_mono(unwrap!(String::try_from(
|
||||||
textbox: TextBox::new(String::from(word)),
|
word
|
||||||
|
)))),
|
||||||
|
textbox: TextBox::new(unwrap!(String::try_from(word))),
|
||||||
offer_words: false,
|
offer_words: false,
|
||||||
wordlist_type,
|
wordlist_type,
|
||||||
can_go_back,
|
can_go_back,
|
||||||
|
@ -181,7 +181,7 @@ impl Bip39Input {
|
|||||||
// Styling the input to reflect already filled word
|
// Styling the input to reflect already filled word
|
||||||
Self {
|
Self {
|
||||||
button: Button::with_icon(theme::ICON_LIST_CHECK).styled(theme::button_pin_confirm()),
|
button: Button::with_icon(theme::ICON_LIST_CHECK).styled(theme::button_pin_confirm()),
|
||||||
textbox: TextBox::new(String::from(word)),
|
textbox: TextBox::new(unwrap!(String::try_from(word))),
|
||||||
multi_tap: MultiTapKeyboard::new(),
|
multi_tap: MultiTapKeyboard::new(),
|
||||||
options_num: bip39::options_num(word),
|
options_num: bip39::options_num(word),
|
||||||
suggested_word: bip39::complete_word(word),
|
suggested_word: bip39::complete_word(word),
|
||||||
|
@ -148,7 +148,7 @@ pub fn long_line_content_with_ellipsis(
|
|||||||
available_width: i16,
|
available_width: i16,
|
||||||
) -> ShortString {
|
) -> ShortString {
|
||||||
if text_font.text_width(text) <= available_width {
|
if text_font.text_width(text) <= available_width {
|
||||||
String::from(text) // whole text can fit
|
unwrap!(String::try_from(text)) // whole text can fit
|
||||||
} else {
|
} else {
|
||||||
// Text is longer, showing its right end with ellipsis at the beginning.
|
// Text is longer, showing its right end with ellipsis at the beginning.
|
||||||
// Finding out how many additional text characters will fit in,
|
// Finding out how many additional text characters will fit in,
|
||||||
|
Loading…
Reference in New Issue
Block a user