1
- use core:: future:: Future ;
2
1
use embedded_storage:: nor_flash:: ErrorType ;
3
2
4
3
/// Read only NOR flash trait.
5
4
pub trait AsyncReadNorFlash : ErrorType {
6
5
/// The minumum number of bytes the storage peripheral can read
7
6
const READ_SIZE : usize ;
8
7
9
- type ReadFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > > + ' a
10
- where
11
- Self : ' a ;
12
-
13
8
/// Read a slice of data from the storage peripheral, starting the read
14
9
/// operation at the given address offset, and reading `bytes.len()` bytes.
15
10
///
16
11
/// # Errors
17
12
///
18
13
/// Returns an error if the arguments are not aligned or out of bounds. The implementation
19
14
/// can use the [`check_read`] helper function.
20
- fn read < ' a > ( & ' a mut self , offset : u32 , bytes : & ' a mut [ u8 ] ) -> Self :: ReadFuture < ' a > ;
15
+ async fn read ( & mut self , offset : u32 , bytes : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > ;
21
16
22
17
/// The capacity of the peripheral in bytes.
23
18
fn capacity ( & self ) -> usize ;
@@ -31,10 +26,6 @@ pub trait AsyncNorFlash: AsyncReadNorFlash {
31
26
/// The minumum number of bytes the storage peripheral can erase
32
27
const ERASE_SIZE : usize ;
33
28
34
- type EraseFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > > + ' a
35
- where
36
- Self : ' a ;
37
-
38
29
/// Erase the given storage range, clearing all data within `[from..to]`.
39
30
/// The given range will contain all 1s afterwards.
40
31
///
@@ -45,11 +36,8 @@ pub trait AsyncNorFlash: AsyncReadNorFlash {
45
36
/// Returns an error if the arguments are not aligned or out of bounds (the case where `to >
46
37
/// from` is considered out of bounds). The implementation can use the [`check_erase`]
47
38
/// helper function.
48
- fn erase < ' a > ( & ' a mut self , from : u32 , to : u32 ) -> Self :: EraseFuture < ' a > ;
39
+ async fn erase ( & mut self , from : u32 , to : u32 ) -> Result < ( ) , Self :: Error > ;
49
40
50
- type WriteFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > > + ' a
51
- where
52
- Self : ' a ;
53
41
/// If power is lost during write, the contents of the written words are undefined,
54
42
/// but the rest of the page is guaranteed to be unchanged.
55
43
/// It is not allowed to write to the same word twice.
@@ -58,5 +46,5 @@ pub trait AsyncNorFlash: AsyncReadNorFlash {
58
46
///
59
47
/// Returns an error if the arguments are not aligned or out of bounds. The implementation
60
48
/// can use the [`check_write`] helper function.
61
- fn write < ' a > ( & ' a mut self , offset : u32 , bytes : & ' a [ u8 ] ) -> Self :: WriteFuture < ' a > ;
49
+ async fn write ( & mut self , offset : u32 , bytes : & [ u8 ] ) -> Result < ( ) , Self :: Error > ;
62
50
}
0 commit comments