···7pub mod merged;
8pub mod pq;
9pub mod record;
010pub mod reftable_iterator;
011pub mod reftable_table;
12pub mod stack;
13pub mod system;
···7pub mod merged;
8pub mod pq;
9pub mod record;
10+pub mod reftable_basics;
11pub mod reftable_iterator;
12+pub mod reftable_record;
13pub mod reftable_table;
14pub mod stack;
15pub mod system;
+41
src/reftable/reftable_basics.rs
···00000000000000000000000000000000000000000
···1+use std::ffi::{c_char, c_uchar};
2+3+/* A buffer that contains arbitrary byte slices. */
4+type ReftableBuf = Vec<c_char>;
5+6+/*
7+ * Hash functions understood by the reftable library. Note that the values are
8+ * arbitrary and somewhat random such that we can easily detect cases where the
9+ * hash hasn't been properly set up.
10+ */
11+enum ReftableHash {
12+ ReftableHashSha1 = 89,
13+ ReftableHashSha256 = 247,
14+}
15+16+const REFTABLE_HASH_SIZE_SHA1: usize = 20;
17+const REFTABLE_HASH_SIZE_SHA256: usize = 32;
18+const REFTABLE_HASH_SIZE_MAX: usize = REFTABLE_HASH_SIZE_SHA256;
19+20+pub struct ReftableWrappedHash {
21+ value: [c_uchar; REFTABLE_HASH_SIZE_MAX],
22+} // Wrapper created so we can implement things like PartialEq on this...
23+24+impl PartialEq<Self> for ReftableWrappedHash {
25+ fn eq(&self, other: &Self) -> bool {
26+ self.value.len() == other.value.len()
27+ && self
28+ .value
29+ .iter()
30+ .zip(other.value.iter())
31+ .all(|(self_byte, other_byte)| self_byte == other_byte)
32+ }
33+}
34+35+impl From<[c_uchar; REFTABLE_HASH_SIZE_MAX]> for ReftableWrappedHash {
36+ fn from(value: [c_uchar; REFTABLE_HASH_SIZE_MAX]) -> Self {
37+ ReftableWrappedHash { value }
38+ }
39+}
40+41+// FIXME: removed reftable_set_alloc ... used only for C memory management