@@ -113,12 +113,11 @@ impl<const PAGES: usize, const BYTES_PER_WORD: usize, const PAGE_WORDS: usize>
113
113
self . current_stats
114
114
}
115
115
116
- #[ cfg( feature = "_test" ) ]
116
+ #[ cfg( any ( test , feature = "_test" ) ) ]
117
117
/// Print all items in flash to the returned string
118
- pub fn print_items ( & mut self ) -> String {
118
+ pub async fn print_items ( & mut self ) -> String {
119
119
use crate :: cache:: NoCache ;
120
120
use crate :: NorFlashExt ;
121
- use futures:: executor:: block_on;
122
121
use std:: fmt:: Write ;
123
122
124
123
let mut buf = [ 0 ; 1024 * 16 ] ;
@@ -132,12 +131,14 @@ impl<const PAGES: usize, const BYTES_PER_WORD: usize, const PAGE_WORDS: usize>
132
131
writeln ! (
133
132
s,
134
133
" Page {page_index} ({}):" ,
135
- match block_on ( crate :: get_page_state(
134
+ match crate :: get_page_state(
136
135
self ,
137
136
Self :: FULL_FLASH_RANGE ,
138
137
& mut NoCache :: new( ) ,
139
138
page_index
140
- ) ) {
139
+ )
140
+ . await
141
+ {
141
142
Ok ( value) => format!( "{value:?}" ) ,
142
143
Err ( e) => format!( "Error ({e:?})" ) ,
143
144
}
@@ -151,13 +152,13 @@ impl<const PAGES: usize, const BYTES_PER_WORD: usize, const PAGE_WORDS: usize>
151
152
- Self :: WORD_SIZE as u32 ;
152
153
153
154
let mut it = crate :: item:: ItemHeaderIter :: new ( page_data_start, page_data_end) ;
154
- while let ( Some ( header) , item_address) =
155
- block_on ( it. traverse ( self , |_, _| false ) ) . unwrap ( )
155
+ while let ( Some ( header) , item_address) = it. traverse ( self , |_, _| false ) . await . unwrap ( )
156
156
{
157
157
let next_item_address = header. next_item_address :: < Self > ( item_address) ;
158
- let maybe_item =
159
- block_on ( header. read_item ( self , & mut buf, item_address, page_data_end) )
160
- . unwrap ( ) ;
158
+ let maybe_item = header
159
+ . read_item ( self , & mut buf, item_address, page_data_end)
160
+ . await
161
+ . unwrap ( ) ;
161
162
writeln ! (
162
163
s,
163
164
" Item {maybe_item:?} at {item_address}..{next_item_address}"
@@ -169,15 +170,14 @@ impl<const PAGES: usize, const BYTES_PER_WORD: usize, const PAGE_WORDS: usize>
169
170
s
170
171
}
171
172
172
- #[ cfg( feature = "_test" ) ]
173
+ #[ cfg( any ( test , feature = "_test" ) ) ]
173
174
/// Get the presence of the item at the given address.
174
175
///
175
176
/// - If some, the item is there.
176
177
/// - If true, the item is present and fine.
177
178
/// - If false, the item is corrupt or erased.
178
- pub fn get_item_presence ( & mut self , target_item_address : u32 ) -> Option < bool > {
179
+ pub async fn get_item_presence ( & mut self , target_item_address : u32 ) -> Option < bool > {
179
180
use crate :: NorFlashExt ;
180
- use futures:: executor:: block_on;
181
181
182
182
if !Self :: FULL_FLASH_RANGE . contains ( & target_item_address) {
183
183
return None ;
@@ -197,14 +197,14 @@ impl<const PAGES: usize, const BYTES_PER_WORD: usize, const PAGE_WORDS: usize>
197
197
198
198
let mut found_item = None ;
199
199
let mut it = crate :: item:: ItemHeaderIter :: new ( page_data_start, page_data_end) ;
200
- while let ( Some ( header) , item_address) = block_on ( it. traverse ( self , |_, _| false ) ) . unwrap ( )
201
- {
200
+ while let ( Some ( header) , item_address) = it. traverse ( self , |_, _| false ) . await . unwrap ( ) {
202
201
let next_item_address = header. next_item_address :: < Self > ( item_address) ;
203
202
204
203
if ( item_address..next_item_address) . contains ( & target_item_address) {
205
- let maybe_item =
206
- block_on ( header. read_item ( self , & mut buf, item_address, page_data_end) )
207
- . unwrap ( ) ;
204
+ let maybe_item = header
205
+ . read_item ( self , & mut buf, item_address, page_data_end)
206
+ . await
207
+ . unwrap ( ) ;
208
208
209
209
match maybe_item {
210
210
crate :: item:: MaybeItem :: Corrupted ( _, _)
0 commit comments