1pub trait CacheKey {
3 fn hash_bytes(&self) -> &[u8];
6}
7
8impl CacheKey for u32 {
9 fn hash_bytes(&self) -> &[u8] {
10 &bytemuck::bytes_of(&*self)
11 }
12}
13
14impl CacheKey for i32 {
15 fn hash_bytes(&self) -> &[u8] {
16 &bytemuck::bytes_of(&*self)
17 }
18}
19
20impl CacheKey for &[u8] {
21 fn hash_bytes(&self) -> &[u8] {
22 self
23 }
24}
25
26impl CacheKey for Vec<u8> {
27 fn hash_bytes(&self) -> &[u8] {
28 &self
29 }
30}
31
32impl CacheKey for Vec<u32> {
33 fn hash_bytes(&self) -> &[u8] {
34 bytemuck::cast_slice(&self)
35 }
36}
37
38impl CacheKey for &str {
39 fn hash_bytes(&self) -> &[u8] {
40 self.as_bytes()
42 }
43}