@@ -4,7 +4,7 @@ use core::{fmt::Debug, ops::Range};
4
4
5
5
use embedded_storage_async:: nor_flash:: NorFlash ;
6
6
7
- use crate :: { item:: ItemHeader , PageState } ;
7
+ use crate :: { item:: ItemHeader , map :: Key , PageState } ;
8
8
9
9
use self :: {
10
10
key_pointers:: { CachedKeyPointers , KeyPointersCache , UncachedKeyPointers } ,
@@ -26,7 +26,7 @@ pub trait CacheImpl: PrivateCacheImpl {}
26
26
27
27
/// Trait implemented by all cache types that know about keys
28
28
#[ allow( private_bounds) ]
29
- pub trait KeyCacheImpl < KEY : Eq > : CacheImpl + PrivateKeyCacheImpl < KEY > { }
29
+ pub trait KeyCacheImpl < KEY : Key > : CacheImpl + PrivateKeyCacheImpl < KEY > { }
30
30
31
31
pub ( crate ) trait Invalidate {
32
32
fn invalidate_cache_state ( & mut self ) ;
@@ -133,7 +133,7 @@ impl<T: PrivateCacheImpl> PrivateCacheImpl for &mut T {
133
133
}
134
134
}
135
135
136
- pub ( crate ) trait PrivateKeyCacheImpl < KEY : Eq > : PrivateCacheImpl {
136
+ pub ( crate ) trait PrivateKeyCacheImpl < KEY : Key > : PrivateCacheImpl {
137
137
type KPC : KeyPointersCache < KEY > ;
138
138
139
139
fn key_pointers ( & mut self ) -> & mut Self :: KPC ;
@@ -142,7 +142,7 @@ pub(crate) trait PrivateKeyCacheImpl<KEY: Eq>: PrivateCacheImpl {
142
142
self . key_pointers ( ) . key_location ( key)
143
143
}
144
144
145
- fn notice_key_location ( & mut self , key : KEY , item_address : u32 , dirty : bool ) {
145
+ fn notice_key_location ( & mut self , key : & KEY , item_address : u32 , dirty : bool ) {
146
146
if dirty {
147
147
self . mark_dirty ( ) ;
148
148
}
@@ -155,7 +155,7 @@ pub(crate) trait PrivateKeyCacheImpl<KEY: Eq>: PrivateCacheImpl {
155
155
}
156
156
}
157
157
158
- impl < KEY : Eq , T : PrivateKeyCacheImpl < KEY > > PrivateKeyCacheImpl < KEY > for & mut T {
158
+ impl < KEY : Key , T : PrivateKeyCacheImpl < KEY > > PrivateKeyCacheImpl < KEY > for & mut T {
159
159
type KPC = T :: KPC ;
160
160
161
161
fn key_pointers ( & mut self ) -> & mut Self :: KPC {
@@ -240,13 +240,13 @@ impl PrivateCacheImpl for NoCache {
240
240
}
241
241
242
242
impl CacheImpl for NoCache { }
243
- impl < KEY : Eq > KeyCacheImpl < KEY > for NoCache { }
243
+ impl < KEY : Key > KeyCacheImpl < KEY > for NoCache { }
244
244
245
245
impl Invalidate for NoCache {
246
246
fn invalidate_cache_state ( & mut self ) { }
247
247
}
248
248
249
- impl < KEY : Eq > PrivateKeyCacheImpl < KEY > for NoCache {
249
+ impl < KEY : Key > PrivateKeyCacheImpl < KEY > for NoCache {
250
250
type KPC = UncachedKeyPointers ;
251
251
252
252
fn key_pointers ( & mut self ) -> & mut Self :: KPC {
@@ -309,7 +309,7 @@ impl<const PAGE_COUNT: usize> PrivateCacheImpl for PageStateCache<PAGE_COUNT> {
309
309
}
310
310
311
311
impl < const PAGE_COUNT : usize > CacheImpl for PageStateCache < PAGE_COUNT > { }
312
- impl < KEY : Eq , const PAGE_COUNT : usize > KeyCacheImpl < KEY > for PageStateCache < PAGE_COUNT > { }
312
+ impl < KEY : Key , const PAGE_COUNT : usize > KeyCacheImpl < KEY > for PageStateCache < PAGE_COUNT > { }
313
313
314
314
impl < const PAGE_COUNT : usize > Invalidate for PageStateCache < PAGE_COUNT > {
315
315
fn invalidate_cache_state ( & mut self ) {
@@ -319,7 +319,7 @@ impl<const PAGE_COUNT: usize> Invalidate for PageStateCache<PAGE_COUNT> {
319
319
}
320
320
}
321
321
322
- impl < KEY : Eq , const PAGE_COUNT : usize > PrivateKeyCacheImpl < KEY > for PageStateCache < PAGE_COUNT > {
322
+ impl < KEY : Key , const PAGE_COUNT : usize > PrivateKeyCacheImpl < KEY > for PageStateCache < PAGE_COUNT > {
323
323
type KPC = UncachedKeyPointers ;
324
324
325
325
fn key_pointers ( & mut self ) -> & mut Self :: KPC {
@@ -382,7 +382,7 @@ impl<const PAGE_COUNT: usize> PrivateCacheImpl for PagePointerCache<PAGE_COUNT>
382
382
}
383
383
384
384
impl < const PAGE_COUNT : usize > CacheImpl for PagePointerCache < PAGE_COUNT > { }
385
- impl < KEY : Eq , const PAGE_COUNT : usize > KeyCacheImpl < KEY > for PagePointerCache < PAGE_COUNT > { }
385
+ impl < KEY : Key , const PAGE_COUNT : usize > KeyCacheImpl < KEY > for PagePointerCache < PAGE_COUNT > { }
386
386
387
387
impl < const PAGE_COUNT : usize > Invalidate for PagePointerCache < PAGE_COUNT > {
388
388
fn invalidate_cache_state ( & mut self ) {
@@ -392,7 +392,7 @@ impl<const PAGE_COUNT: usize> Invalidate for PagePointerCache<PAGE_COUNT> {
392
392
}
393
393
}
394
394
395
- impl < KEY : Eq , const PAGE_COUNT : usize > PrivateKeyCacheImpl < KEY > for PagePointerCache < PAGE_COUNT > {
395
+ impl < KEY : Key , const PAGE_COUNT : usize > PrivateKeyCacheImpl < KEY > for PagePointerCache < PAGE_COUNT > {
396
396
type KPC = UncachedKeyPointers ;
397
397
398
398
fn key_pointers ( & mut self ) -> & mut Self :: KPC {
@@ -417,14 +417,14 @@ impl<KEY: Eq, const PAGE_COUNT: usize> PrivateKeyCacheImpl<KEY> for PagePointerC
417
417
/// the chance of a cache hit.
418
418
/// The keys are cached in a fifo and any time its location is updated in cache it's added to the front.
419
419
#[ derive( Debug ) ]
420
- pub struct KeyPointerCache < const PAGE_COUNT : usize , KEY : Eq , const KEYS : usize > {
420
+ pub struct KeyPointerCache < const PAGE_COUNT : usize , KEY : Key , const KEYS : usize > {
421
421
dirt_tracker : DirtTracker ,
422
422
page_states : CachedPageStates < PAGE_COUNT > ,
423
423
page_pointers : CachedPagePointers < PAGE_COUNT > ,
424
424
key_pointers : CachedKeyPointers < KEY , KEYS > ,
425
425
}
426
426
427
- impl < const PAGE_COUNT : usize , KEY : Eq , const KEYS : usize > KeyPointerCache < PAGE_COUNT , KEY , KEYS > {
427
+ impl < const PAGE_COUNT : usize , KEY : Key , const KEYS : usize > KeyPointerCache < PAGE_COUNT , KEY , KEYS > {
428
428
/// Construct a new instance
429
429
pub const fn new ( ) -> Self {
430
430
Self {
@@ -436,15 +436,15 @@ impl<const PAGE_COUNT: usize, KEY: Eq, const KEYS: usize> KeyPointerCache<PAGE_C
436
436
}
437
437
}
438
438
439
- impl < const PAGE_COUNT : usize , KEY : Eq , const KEYS : usize > Default
439
+ impl < const PAGE_COUNT : usize , KEY : Key , const KEYS : usize > Default
440
440
for KeyPointerCache < PAGE_COUNT , KEY , KEYS >
441
441
{
442
442
fn default ( ) -> Self {
443
443
Self :: new ( )
444
444
}
445
445
}
446
446
447
- impl < const PAGE_COUNT : usize , KEY : Eq , const KEYS : usize > PrivateCacheImpl
447
+ impl < const PAGE_COUNT : usize , KEY : Key , const KEYS : usize > PrivateCacheImpl
448
448
for KeyPointerCache < PAGE_COUNT , KEY , KEYS >
449
449
{
450
450
type PSC = CachedPageStates < PAGE_COUNT > ;
@@ -463,16 +463,16 @@ impl<const PAGE_COUNT: usize, KEY: Eq, const KEYS: usize> PrivateCacheImpl
463
463
}
464
464
}
465
465
466
- impl < const PAGE_COUNT : usize , KEY : Eq , const KEYS : usize > CacheImpl
466
+ impl < const PAGE_COUNT : usize , KEY : Key , const KEYS : usize > CacheImpl
467
467
for KeyPointerCache < PAGE_COUNT , KEY , KEYS >
468
468
{
469
469
}
470
- impl < const PAGE_COUNT : usize , KEY : Eq , const KEYS : usize > KeyCacheImpl < KEY >
470
+ impl < const PAGE_COUNT : usize , KEY : Key , const KEYS : usize > KeyCacheImpl < KEY >
471
471
for KeyPointerCache < PAGE_COUNT , KEY , KEYS >
472
472
{
473
473
}
474
474
475
- impl < const PAGE_COUNT : usize , KEY : Eq , const KEYS : usize > Invalidate
475
+ impl < const PAGE_COUNT : usize , KEY : Key , const KEYS : usize > Invalidate
476
476
for KeyPointerCache < PAGE_COUNT , KEY , KEYS >
477
477
{
478
478
fn invalidate_cache_state ( & mut self ) {
@@ -483,7 +483,7 @@ impl<const PAGE_COUNT: usize, KEY: Eq, const KEYS: usize> Invalidate
483
483
}
484
484
}
485
485
486
- impl < const PAGE_COUNT : usize , KEY : Eq , const KEYS : usize > PrivateKeyCacheImpl < KEY >
486
+ impl < const PAGE_COUNT : usize , KEY : Key , const KEYS : usize > PrivateKeyCacheImpl < KEY >
487
487
for KeyPointerCache < PAGE_COUNT , KEY , KEYS >
488
488
{
489
489
type KPC = CachedKeyPointers < KEY , KEYS > ;
0 commit comments