qualia_core_db/net/qdnf/fixtures/
ids.rs1use crate::net::qdnf::types::{Generation, LinkId, OperationId, QHashIndex, StrongDigest};
6
7pub const STRONG_DIGEST_LEN: usize = 48;
9
10pub const QHASH_INDEX_LEN: usize = 8;
12
13#[inline]
15pub fn short_hash_is_authority() -> bool {
16 false
17}
18
19#[inline]
21pub fn digest_sizes_match_types() -> bool {
22 core::mem::size_of::<StrongDigest>() == STRONG_DIGEST_LEN
23 && core::mem::size_of::<QHashIndex>() == QHASH_INDEX_LEN
24 && core::mem::size_of::<Generation>() == 8
25 && core::mem::size_of::<OperationId>() == 16
26 && core::mem::size_of::<LinkId>() == 16
27}
28
29#[cfg(test)]
30mod tests {
31 use super::*;
32
33 #[test]
34 fn digest_size_table_matches_types() {
35 assert!(digest_sizes_match_types());
36 assert_eq!(core::mem::size_of::<StrongDigest>(), 48);
37 assert_eq!(core::mem::size_of::<QHashIndex>(), 8);
38 assert_eq!(core::mem::size_of::<Generation>(), 8);
39 assert_eq!(core::mem::size_of::<OperationId>(), 16);
40 assert_eq!(core::mem::size_of::<LinkId>(), 16);
41 assert_ne!(STRONG_DIGEST_LEN, QHASH_INDEX_LEN);
42 }
43
44 #[test]
45 fn short_hash_is_lookup_index_only() {
46 assert!(!short_hash_is_authority());
47 }
48}