associative_cache/capacity.rs
1//! Constant cache capacity implementations.
2
3use super::Capacity;
4
5macro_rules! define_capacity {
6 ( $( $(#[$attr:meta])* $name:ident => $n:expr; )* ) => {
7 $(
8 $( #[$attr] )*
9 #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
10 pub struct $name;
11
12 impl Capacity for $name {
13 const CAPACITY: usize = $n;
14 }
15 )*
16 }
17}
18
19define_capacity! {
20 /// Constant cache capacity = 1.
21 Capacity1 => 1;
22 /// Constant cache capacity = 2.
23 Capacity2 => 2;
24 /// Constant cache capacity = 4.
25 Capacity4 => 4;
26 /// Constant cache capacity = 8.
27 Capacity8 => 8;
28 /// Constant cache capacity = 16.
29 Capacity16 => 16;
30 /// Constant cache capacity = 32.
31 Capacity32 => 32;
32 /// Constant cache capacity = 64.
33 Capacity64 => 64;
34 /// Constant cache capacity = 128.
35 Capacity128 => 128;
36 /// Constant cache capacity = 256.
37 Capacity256 => 256;
38 /// Constant cache capacity = 512.
39 Capacity512 => 512;
40 /// Constant cache capacity = 1024.
41 Capacity1024 => 1024;
42 /// Constant cache capacity = 2048.
43 Capacity2048 => 2048;
44 /// Constant cache capacity = 4096.
45 Capacity4096 => 4096;
46 /// Constant cache capacity = 8192.
47 Capacity8192 => 8192;
48}