@@ -11,7 +11,7 @@ use crate::CommandDisableApp;
1111
1212const ENABLED_OFFSET : u64 = 8 ;
1313const CHECKSUM_OFFSET : u64 = 12 ;
14-
14+
1515#[ async_trait]
1616impl CommandDisableApp for ProbeRSConnection {
1717 async fn disable_app (
@@ -23,7 +23,8 @@ impl CommandDisableApp for ProbeRSConnection {
2323 return Err ( InternalError :: ConnectionNotOpen . into ( ) ) ;
2424 }
2525 let session = self . session . as_mut ( ) . expect ( "Board must be open" ) ;
26- ' outer: loop { // this loop is labeled so we can exit early if the app is already disabled
26+ ' outer: loop {
27+ // this loop is labeled so we can exit early if the app is already disabled
2728 let mut installed_apps: Vec < AppData > = Vec :: new ( ) ;
2829 let mut index: u8 = 1 ;
2930 let mut appaddr: u64 = settings. start_address ;
@@ -76,9 +77,13 @@ impl CommandDisableApp for ProbeRSConnection {
7677 address : appaddr,
7778 name : pname,
7879 size : app_size,
79- checksum : u32:: from_ne_bytes ( header_data[ CHECKSUM_OFFSET as usize ..CHECKSUM_OFFSET as usize + 4 ] . try_into ( ) . unwrap ( ) ) ,
80+ checksum : u32:: from_ne_bytes (
81+ header_data[ CHECKSUM_OFFSET as usize ..CHECKSUM_OFFSET as usize + 4 ]
82+ . try_into ( )
83+ . unwrap ( ) ,
84+ ) ,
8085 index,
81- enabled : if header_data[ ENABLED_OFFSET as usize ] == 1 { true } else { false } ,
86+ enabled : header_data[ ENABLED_OFFSET as usize ] == 1 ,
8287 } ) ;
8388 // log::info!("found checksum {:?}", (installed_apps[index as usize].checksum).to_ne_bytes());
8489 // log::info!("changing checksum will result in {:?}", (installed_apps[index as usize].checksum - 1).to_ne_bytes());
@@ -99,7 +104,10 @@ impl CommandDisableApp for ProbeRSConnection {
99104 let mut app: & AppData ;
100105 match app_name {
101106 Some ( app_name) => {
102- app = match installed_apps. iter ( ) . find ( |iter| iter. name == app_name && iter. enabled == true ) {
107+ app = match installed_apps
108+ . iter ( )
109+ . find ( |iter| iter. name == app_name && iter. enabled )
110+ {
103111 Some ( app) => app,
104112 None => break ,
105113 }
@@ -121,32 +129,39 @@ impl CommandDisableApp for ProbeRSConnection {
121129 . unwrap ( )
122130 == "Confirm"
123131 {
124- if app. enabled == false {
132+ if ! app. enabled {
125133 println ! ( "App is already disabled!" ) ;
126- break ' outer; // exit from the big loop, we don't have to do anything else
134+ break ' outer; // exit from the big loop, we don't have to do anything else
127135 }
128- break
136+ break ;
129137 }
130138 } ,
131139 }
132140 let mut loader = session. target ( ) . flash_loader ( ) ;
133- if app. index == 0 { // ALL
141+ if app. index == 0 {
142+ // ALL
134143 // log::info!("ALL");
135144 for app_iter in installed_apps[ 1 ..] . iter ( ) {
136145 // log::info!("checking app {}", app_iter.name);
137- if app_iter. enabled == true {
146+ if app_iter. enabled {
138147 // log::info!("entered here????");
139148 loader. add_data ( app_iter. address + ENABLED_OFFSET , & [ 0x0 ] ) ?;
140- loader. add_data ( app_iter. address + CHECKSUM_OFFSET , & ( app_iter. checksum - 1 ) . to_ne_bytes ( ) ) ?; // the checksum must be increased or we'll invalidate the header
149+ loader. add_data (
150+ app_iter. address + CHECKSUM_OFFSET ,
151+ & ( app_iter. checksum - 1 ) . to_ne_bytes ( ) ,
152+ ) ?; // the checksum must be increased or we'll invalidate the header
141153 }
142154 }
143- }
144- else { // only one
155+ } else {
156+ // only one
145157 loader. add_data ( app. address + ENABLED_OFFSET , & [ 0x0 ] ) ?;
146- loader. add_data ( app. address + CHECKSUM_OFFSET , & ( app. checksum - 1 ) . to_ne_bytes ( ) ) ?; // the checksum must be increased or we'll invalidate the header
158+ loader. add_data (
159+ app. address + CHECKSUM_OFFSET ,
160+ & ( app. checksum - 1 ) . to_ne_bytes ( ) ,
161+ ) ?; // the checksum must be increased or we'll invalidate the header
147162 }
148163 let mut options = DownloadOptions :: default ( ) ;
149- options. keep_unwritten_bytes = true ;
164+ options. keep_unwritten_bytes = true ;
150165 loader. commit ( session, options) ?;
151166
152167 if app_name. is_none ( ) {
0 commit comments