@@ -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,11 @@ 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
+ ///
391
+ /// See the readme for more info about the constraints on item sizes.
392
+ ItemTooBig ,
384
393
}
385
394
386
395
impl < S > From < SerializationError > for Error < S > {
@@ -416,6 +425,7 @@ where
416
425
"A provided buffer was to small to be used. Needed was {needed}"
417
426
) ,
418
427
Error :: SerializationError ( value) => write ! ( f, "Map value error: {value}" ) ,
428
+ Error :: ItemTooBig => write ! ( f, "The item is too big to fit in the flash" ) ,
419
429
}
420
430
}
421
431
}
0 commit comments