@peerbit/riblt 0.0.1-5cf61cb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +101 -0
- package/package.json +58 -0
- package/src/encoding.rs +397 -0
- package/src/lib.rs +7 -0
- package/src/sketch.rs +101 -0
- package/src/testing.rs +50 -0
- package/src/tests.rs +2343 -0
- package/src/wasm.rs +173 -0
package/src/testing.rs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
use crate::encoding::Symbol;
|
|
2
|
+
|
|
3
|
+
#[allow(deprecated)]
|
|
4
|
+
use std::hash::{Hasher, SipHasher};
|
|
5
|
+
|
|
6
|
+
const TEST_SYMBOL_SIZE: usize = 64;
|
|
7
|
+
|
|
8
|
+
pub type TestSymbol = [u8; TEST_SYMBOL_SIZE];
|
|
9
|
+
|
|
10
|
+
pub fn new_test_symbol(x: u64) -> TestSymbol {
|
|
11
|
+
return core::array::from_fn::<u8, TEST_SYMBOL_SIZE, _>(|i| {
|
|
12
|
+
x.checked_shr(8 * i as u32).unwrap_or(0) as u8
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
impl Symbol for TestSymbol {
|
|
17
|
+
fn zero() -> TestSymbol {
|
|
18
|
+
return new_test_symbol(0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fn xor(&self, other: &TestSymbol) -> TestSymbol {
|
|
22
|
+
return core::array::from_fn(|i| self[i] ^ other[i]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#[allow(deprecated)]
|
|
26
|
+
fn hash(&self) -> u64 {
|
|
27
|
+
let mut hasher = SipHasher::new_with_keys(567, 890);
|
|
28
|
+
hasher.write(self);
|
|
29
|
+
return hasher.finish();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
pub type TestU64 = u64;
|
|
34
|
+
|
|
35
|
+
impl Symbol for TestU64 {
|
|
36
|
+
fn zero() -> TestU64 {
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fn xor(&self, other: &TestU64) -> TestU64 {
|
|
41
|
+
return self ^ other;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#[allow(deprecated)]
|
|
45
|
+
fn hash(&self) -> u64 {
|
|
46
|
+
let mut hasher = SipHasher::new_with_keys(123, 456);
|
|
47
|
+
hasher.write_u64(*self);
|
|
48
|
+
return hasher.finish();
|
|
49
|
+
}
|
|
50
|
+
}
|