Skip to content

Commit a289e61

Browse files
committed
wip: restructure reshuffle_apps
Signed-off-by: Eva Cosma <eva.cosma.mail@gmail.com>
1 parent d9c0012 commit a289e61

4 files changed

Lines changed: 259 additions & 260 deletions

File tree

tbf-parser/src/parse.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,10 @@ pub fn parse_tbf_header(
203203
}
204204
types::TbfHeaderTypes::TbfHeaderWriteableFlashRegions => {
205205
// Length must be a multiple of the size of a region definition.
206-
if tlv_header.length as usize
207-
% mem::size_of::<types::TbfHeaderV2WriteableFlashRegion>()
208-
== 0
206+
if (tlv_header.length as usize)
207+
.is_multiple_of(mem::size_of::<
208+
types::TbfHeaderV2WriteableFlashRegion,
209+
>())
209210
{
210211
// Calculate how many writeable flash regions
211212
// there are specified in this header.

tockloader-lib/src/attributes/app_attributes.rs

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,8 @@ use crate::IO;
2121
#[derive(Debug, Clone)]
2222
pub struct AppAttributes {
2323
pub address: u64,
24-
pub size: u32,
25-
pub index: u8,
2624
pub tbf_header: TbfHeader,
2725
pub tbf_footers: Vec<TbfFooter>,
28-
pub installed: bool,
29-
pub is_padding: bool,
30-
}
31-
32-
impl std::fmt::Display for AppAttributes {
33-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
34-
write!(
35-
f,
36-
"{}. {} - start: {:#x}, size: {}",
37-
self.index,
38-
self.tbf_header.get_package_name().unwrap_or(""),
39-
self.address,
40-
self.size
41-
)
42-
}
4326
}
4427

4528
/// This structure represents a footer of a Tock application. Currently, footers
@@ -62,20 +45,13 @@ impl TbfFooter {
6245
impl AppAttributes {
6346
pub(crate) fn new(
6447
address: u64,
65-
size: u32,
66-
index: u8,
6748
header_data: TbfHeader,
6849
footers_data: Vec<TbfFooter>,
69-
installed: bool,
7050
) -> AppAttributes {
7151
AppAttributes {
7252
address,
73-
size,
74-
index,
7553
tbf_header: header_data,
7654
tbf_footers: footers_data,
77-
installed,
78-
is_padding: false,
7955
}
8056
}
8157

@@ -178,10 +154,9 @@ impl AppAttributes {
178154
footer_offset += footer_info.1 + 4;
179155
}
180156

181-
let details: AppAttributes =
182-
AppAttributes::new(appaddr, total_size, apps_counter, header, footers, true);
157+
let details: AppAttributes = AppAttributes::new(appaddr, header, footers);
183158

184-
apps_details.insert(apps_counter.into(), details);
159+
apps_details.insert(apps_counter, details);
185160
apps_counter += 1;
186161
appaddr += total_size as u64;
187162
}
@@ -316,10 +291,9 @@ impl AppAttributes {
316291
footer_offset += footer_info.1 + 4;
317292
}
318293

319-
let details: AppAttributes =
320-
AppAttributes::new(appaddr, total_size, apps_counter, header, footers, true);
294+
let details: AppAttributes = AppAttributes::new(appaddr, header, footers);
321295

322-
apps_details.insert(apps_counter.into(), details);
296+
apps_details.insert(apps_counter, details);
323297
apps_counter += 1;
324298
appaddr += total_size as u64;
325299
}

tockloader-lib/src/command_impl/install.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use async_trait::async_trait;
22

33
use crate::attributes::app_attributes::AppAttributes;
44
use crate::board_settings::BoardSettings;
5-
use crate::command_impl::reshuffle_apps::{create_pkt, reconstruct_app, reshuffle_apps};
5+
use crate::command_impl::reshuffle_apps::{create_pkt, reshuffle_apps};
66
use crate::connection::TockloaderConnection;
77
use crate::errors::TockloaderError;
88
use crate::tabs::tab::Tab;
@@ -15,10 +15,8 @@ impl CommandInstall for TockloaderConnection {
1515
settings: &BoardSettings,
1616
tab: Tab,
1717
) -> Result<(), TockloaderError> {
18-
// get the already installed apps
1918
let mut installed_apps: Vec<AppAttributes> = self.list(settings).await.unwrap();
2019

21-
// reconstruct the new app
2220
if let Some(mut app) = reconstruct_app(Some(&tab), settings) {
2321
app.index = installed_apps.len() as u8;
2422
installed_apps.push(app.clone());

0 commit comments

Comments
 (0)