1- use core:: future:: Future ;
21use embedded_storage:: nor_flash:: ErrorType ;
32
43/// Read only NOR flash trait.
54pub trait AsyncReadNorFlash : ErrorType {
65 /// The minumum number of bytes the storage peripheral can read
76 const READ_SIZE : usize ;
87
9- type ReadFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > > + ' a
10- where
11- Self : ' a ;
12-
138 /// Read a slice of data from the storage peripheral, starting the read
149 /// operation at the given address offset, and reading `bytes.len()` bytes.
1510 ///
1611 /// # Errors
1712 ///
1813 /// Returns an error if the arguments are not aligned or out of bounds. The implementation
1914 /// 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 > ;
2116
2217 /// The capacity of the peripheral in bytes.
2318 fn capacity ( & self ) -> usize ;
@@ -31,10 +26,6 @@ pub trait AsyncNorFlash: AsyncReadNorFlash {
3126 /// The minumum number of bytes the storage peripheral can erase
3227 const ERASE_SIZE : usize ;
3328
34- type EraseFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > > + ' a
35- where
36- Self : ' a ;
37-
3829 /// Erase the given storage range, clearing all data within `[from..to]`.
3930 /// The given range will contain all 1s afterwards.
4031 ///
@@ -45,11 +36,8 @@ pub trait AsyncNorFlash: AsyncReadNorFlash {
4536 /// Returns an error if the arguments are not aligned or out of bounds (the case where `to >
4637 /// from` is considered out of bounds). The implementation can use the [`check_erase`]
4738 /// 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 > ;
4940
50- type WriteFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > > + ' a
51- where
52- Self : ' a ;
5341 /// If power is lost during write, the contents of the written words are undefined,
5442 /// but the rest of the page is guaranteed to be unchanged.
5543 /// It is not allowed to write to the same word twice.
@@ -58,5 +46,5 @@ pub trait AsyncNorFlash: AsyncReadNorFlash {
5846 ///
5947 /// Returns an error if the arguments are not aligned or out of bounds. The implementation
6048 /// 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 > ;
6250}
0 commit comments