Skip to content

Commit ee1b2c6

Browse files
committed
refactor: remove read_binary
Signed-off-by: addrian-77 <lunguadrian30@gmail.com>
1 parent 125ab07 commit ee1b2c6

4 files changed

Lines changed: 125 additions & 221 deletions

File tree

tockloader-lib/src/attributes/app_attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::errors::{TockError, TockloaderError};
1717
/// All data is stored either within [TbfHeader]s, or [TbfFooter]s.
1818
///
1919
/// See also <https://book.tockos.org/doc/tock_binary_format>
20-
#[derive(Debug, Clone)]
20+
#[derive(Debug)]
2121
pub struct AppAttributes {
2222
pub address: u64,
2323
pub tbf_header: TbfHeader,

tockloader-lib/src/command_impl/install.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,28 @@ impl CommandInstall for TockloaderConnection {
1818
let app_attributes_list: Vec<AppAttributes> = self.list(settings).await.unwrap();
1919
let mut tock_app_list = app_attributes_list
2020
.iter()
21-
.map(|app| TockApp::from_app_attributes(app, settings))
21+
.map(TockApp::from_app_attributes)
2222
.collect::<Vec<TockApp>>();
2323

2424
// obtain the binaries in a vector
2525
let mut app_binaries: Vec<Vec<u8>> = Vec::new();
2626

27-
for app in tock_app_list.iter() {
28-
app_binaries.push(app.clone().read_binary(self).await.unwrap())
27+
let mut address = settings.start_address;
28+
for app in app_attributes_list.iter() {
29+
app_binaries.push(
30+
self.read(address, app.tbf_header.total_size() as usize)
31+
.await
32+
.unwrap(),
33+
);
34+
address += app.tbf_header.total_size() as u64;
2935
}
3036

3137
let mut app = TockApp::from_tab(&tab, settings).unwrap();
3238

3339
app.replace_idx(tock_app_list.len());
3440
tock_app_list.push(app.clone());
3541

36-
app_binaries.push(
37-
tab.extract_binary(settings.arch.as_ref().unwrap().as_str())
38-
.unwrap(),
39-
);
42+
app_binaries.push(tab.extract_binary(settings.arch.clone().unwrap()).unwrap());
4043

4144
let configuration = reshuffle_apps(settings, tock_app_list).unwrap();
4245

0 commit comments

Comments
 (0)