File tree Expand file tree Collapse file tree 5 files changed +30
-10
lines changed Expand file tree Collapse file tree 5 files changed +30
-10
lines changed Original file line number Diff line number Diff line change 1
1
# espflash
2
2
3
- ![ GitHub Workflow Status] ( https://img.shields.io/github/actions/workflow/status/esp-rs/espflash/rust.yml?branch=main&logoColor =1C2C2E&style=flat-square )
3
+ ![ GitHub Workflow Status] ( https://img.shields.io/github/actions/workflow/status/esp-rs/espflash/rust.yml?branch=main&labelColor =1C2C2E&logo=github &style=flat-square )
4
4
![ Crates.io] ( https://img.shields.io/crates/l/espflash?labelColor=1C2C2E&style=flat-square )
5
5
[ ![ Matrix] ( https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&color=BEC5C9&labelColor=1C2C2E&logo=matrix&style=flat-square )] ( https://matrix.to/#/#esp-rs:matrix.org )
6
6
Original file line number Diff line number Diff line change
1
+ //! Send commands to a target device
2
+
1
3
use std:: { io:: Write , mem:: size_of, time:: Duration } ;
2
4
3
5
use bytemuck:: { bytes_of, Pod , Zeroable } ;
Original file line number Diff line number Diff line change @@ -131,7 +131,9 @@ impl FlashTarget for Esp32Target {
131
131
let chunks = compressed. chunks ( flash_write_size) ;
132
132
let num_chunks = chunks. len ( ) ;
133
133
134
- progress. as_mut ( ) . map ( |cb| cb. init ( addr, num_chunks) ) ;
134
+ if let Some ( cb) = progress. as_mut ( ) {
135
+ cb. init ( addr, num_chunks)
136
+ }
135
137
136
138
// decode the chunks to see how much data the device will have to save
137
139
let mut decoder = ZlibDecoder :: new ( Vec :: new ( ) ) ;
@@ -156,10 +158,14 @@ impl FlashTarget for Esp32Target {
156
158
} ,
157
159
) ?;
158
160
159
- progress. as_mut ( ) . map ( |cb| cb. update ( i + 1 ) ) ;
161
+ if let Some ( cb) = progress. as_mut ( ) {
162
+ cb. update ( i + 1 )
163
+ }
160
164
}
161
165
162
- progress. as_mut ( ) . map ( |cb| cb. finish ( ) ) ;
166
+ if let Some ( cb) = progress. as_mut ( ) {
167
+ cb. finish ( )
168
+ }
163
169
164
170
Ok ( ( ) )
165
171
}
Original file line number Diff line number Diff line change @@ -57,7 +57,9 @@ impl FlashTarget for Esp8266Target {
57
57
let chunks = segment. data . chunks ( FLASH_WRITE_SIZE ) ;
58
58
let num_chunks = chunks. len ( ) ;
59
59
60
- progress. as_mut ( ) . map ( |cb| cb. init ( addr, num_chunks) ) ;
60
+ if let Some ( cb) = progress. as_mut ( ) {
61
+ cb. init ( addr, num_chunks)
62
+ }
61
63
62
64
for ( i, block) in chunks. enumerate ( ) {
63
65
connection. command ( Command :: FlashData {
@@ -67,10 +69,14 @@ impl FlashTarget for Esp8266Target {
67
69
data : block,
68
70
} ) ?;
69
71
70
- progress. as_mut ( ) . map ( |cb| cb. update ( i + 1 ) ) ;
72
+ if let Some ( cb) = progress. as_mut ( ) {
73
+ cb. update ( i + 1 )
74
+ }
71
75
}
72
76
73
- progress. as_mut ( ) . map ( |cb| cb. finish ( ) ) ;
77
+ if let Some ( cb) = progress. as_mut ( ) {
78
+ cb. finish ( )
79
+ }
74
80
75
81
Ok ( ( ) )
76
82
}
Original file line number Diff line number Diff line change @@ -63,7 +63,9 @@ impl FlashTarget for RamTarget {
63
63
let chunks = segment. data . chunks ( self . block_size ) ;
64
64
let num_chunks = chunks. len ( ) ;
65
65
66
- progress. as_mut ( ) . map ( |cb| cb. init ( addr, num_chunks) ) ;
66
+ if let Some ( cb) = progress. as_mut ( ) {
67
+ cb. init ( addr, num_chunks)
68
+ }
67
69
68
70
for ( i, block) in chunks. enumerate ( ) {
69
71
connection. command ( Command :: MemData {
@@ -73,10 +75,14 @@ impl FlashTarget for RamTarget {
73
75
data : block,
74
76
} ) ?;
75
77
76
- progress. as_mut ( ) . map ( |cb| cb. update ( i + 1 ) ) ;
78
+ if let Some ( cb) = progress. as_mut ( ) {
79
+ cb. update ( i + 1 )
80
+ }
77
81
}
78
82
79
- progress. as_mut ( ) . map ( |cb| cb. finish ( ) ) ;
83
+ if let Some ( cb) = progress. as_mut ( ) {
84
+ cb. finish ( )
85
+ }
80
86
81
87
Ok ( ( ) )
82
88
}
You can’t perform that action at this time.
0 commit comments