dualcache_ff/static_cache/stub.rs
1use core::marker::PhantomData;
2
3/// A zero-overhead, completely compiled-away stub implementation of the DualCache API.
4/// All methods are marked with `#[inline(always)]` and evaluate to no-ops.
5/// Suitable for ultra-constrained bare-metal environments where caching is compiled out.
6#[derive(Debug, Clone)]
7pub struct DualCacheStub<K, V> {
8 _marker: PhantomData<(K, V)>,
9}
10
11impl<K, V> DualCacheStub<K, V> {
12 /// Create a new stub cache instance (which does nothing).
13 #[inline(always)]
14 pub fn new(_config: crate::Config) -> Self {
15 Self {
16 _marker: PhantomData,
17 }
18 }
19
20 /// Exposes API parity with `DualCacheFF::new_headless`
21 #[inline(always)]
22 pub fn new_headless(_config: crate::Config) -> (Self, ()) {
23 (
24 Self {
25 _marker: PhantomData,
26 },
27 (),
28 )
29 }
30
31 /// Exposes API parity with `DualCacheFF::get`
32 #[inline(always)]
33 pub fn get(&self, _key: &K) -> Option<V> {
34 None
35 }
36
37 /// Exposes API parity with `DualCacheFF::insert`
38 #[inline(always)]
39 pub fn insert(&self, _key: K, _value: V) {}
40
41 /// Exposes API parity with `DualCacheFF::remove`
42 #[inline(always)]
43 pub fn remove(&self, _key: &K) {}
44
45 /// Exposes API parity with `DualCacheFF::clear`
46 #[inline(always)]
47 pub fn clear(&self) {}
48
49 /// Exposes API parity with `DualCacheFF::sync`
50 #[inline(always)]
51 pub fn sync(&self) {}
52}