@@ -148,6 +148,11 @@ const fn calculate_page_index<S: NorFlash>(flash_range: Range<u32>, address: u32
148
148
( address - flash_range. start ) as usize / S :: ERASE_SIZE
149
149
}
150
150
151
+ const fn calculate_page_size < S : NorFlash > ( ) -> usize {
152
+ // Page minus the two page status words
153
+ S :: ERASE_SIZE - S :: WORD_SIZE * 2
154
+ }
155
+
151
156
/// The marker being used for page states
152
157
const MARKER : u8 = 0 ;
153
158
@@ -366,7 +371,6 @@ pub enum Error<S> {
366
371
backtrace : std:: backtrace:: Backtrace ,
367
372
} ,
368
373
/// The item cannot be stored anymore because the storage is full.
369
- /// If you get this error some data may be lost.
370
374
FullStorage ,
371
375
/// It's been detected that the memory is likely corrupted.
372
376
/// You may want to erase the memory to recover.
@@ -381,6 +385,9 @@ pub enum Error<S> {
381
385
BufferTooSmall ( usize ) ,
382
386
/// A serialization error (from the key or value)
383
387
SerializationError ( SerializationError ) ,
388
+ /// The item does not fit in flash, ever.
389
+ /// This is different from [Error::FullStorage] because this item is too big to fit even in empty flash.
390
+ ItemTooBig ,
384
391
}
385
392
386
393
impl < S > From < SerializationError > for Error < S > {
@@ -416,6 +423,7 @@ where
416
423
"A provided buffer was to small to be used. Needed was {needed}"
417
424
) ,
418
425
Error :: SerializationError ( value) => write ! ( f, "Map value error: {value}" ) ,
426
+ Error :: ItemTooBig => write ! ( f, "The item is too big to fit in the flash" ) ,
419
427
}
420
428
}
421
429
}
0 commit comments