hara_native/lang/protocol/
ihash.rs1use hara_protocol_macros::hara_protocol;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum HashType {
5 System,
6 Rapid,
7 Murmur3,
8 Sip,
9}
10
11#[hara_protocol(namespace = "std.protocol.ihash", name = "IHash")]
12pub trait IHash {
13 fn hash_calc(&self, hash_type: HashType) -> u64;
14
15 #[hara_method(value = "hash", arity = 1)]
16 fn hash(&self) -> u64 {
17 self.hash_calc(self.hash_type())
18 }
19
20 fn hash_get(&self) -> u64 {
21 self.hash()
22 }
23
24 fn hash_get_as(&self, hash_type: HashType) -> u64 {
25 self.hash_calc(hash_type)
26 }
27
28 fn hash_type(&self) -> HashType {
29 HashType::Rapid
30 }
31}