File tree Expand file tree Collapse file tree 4 files changed +22
-18
lines changed
embedded-storage-async/src Expand file tree Collapse file tree 4 files changed +22
-18
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
8
8
## Unreleased
9
9
10
- No unreleased changes yet
10
+ - Add ` start() ` and ` end() ` method to the ` Region ` trait.
11
11
12
12
## [ 0.3.1] - 2023-12-04
13
13
Original file line number Diff line number Diff line change @@ -102,17 +102,15 @@ impl Page {
102
102
size,
103
103
}
104
104
}
105
-
106
- /// The end address of the page
107
- const fn end ( & self ) -> u32 {
108
- self . start + self . size as u32
109
- }
110
105
}
111
106
112
107
impl Region for Page {
113
- /// Checks if an address offset is contained within the page
114
- fn contains ( & self , address : u32 ) -> bool {
115
- ( self . start <= address) && ( self . end ( ) > address)
108
+ fn start ( & self ) -> u32 {
109
+ self . start
110
+ }
111
+
112
+ fn end ( & self ) -> u32 {
113
+ self . start + self . size as u32
116
114
}
117
115
}
118
116
Original file line number Diff line number Diff line change @@ -15,8 +15,16 @@ pub mod nor_flash;
15
15
16
16
/// A region denotes a contiguous piece of memory between two addresses.
17
17
pub trait Region {
18
+ /// Start address of the region of `Self`
19
+ fn start ( & self ) -> u32 ;
20
+
21
+ /// End address of the region of `Self`
22
+ fn end ( & self ) -> u32 ;
23
+
18
24
/// Check if `address` is contained in the region of `Self`
19
- fn contains ( & self , address : u32 ) -> bool ;
25
+ fn contains ( & self , address : u32 ) -> bool {
26
+ ( address >= self . start ( ) ) && ( address < self . end ( ) )
27
+ }
20
28
}
21
29
22
30
/// Transparent read only storage trait
Original file line number Diff line number Diff line change @@ -202,17 +202,15 @@ impl Page {
202
202
size,
203
203
}
204
204
}
205
-
206
- /// The end address of the page
207
- const fn end ( & self ) -> u32 {
208
- self . start + self . size as u32
209
- }
210
205
}
211
206
212
207
impl Region for Page {
213
- /// Checks if an address offset is contained within the page
214
- fn contains ( & self , address : u32 ) -> bool {
215
- ( self . start <= address) && ( self . end ( ) > address)
208
+ fn start ( & self ) -> u32 {
209
+ self . start
210
+ }
211
+
212
+ fn end ( & self ) -> u32 {
213
+ self . start + self . size as u32
216
214
}
217
215
}
218
216
You can’t perform that action at this time.
0 commit comments