···77pub mod merged;
88pub mod pq;
99pub mod record;
1010+pub mod reftable_basics;
1011pub mod reftable_iterator;
1212+pub mod reftable_record;
1113pub mod reftable_table;
1214pub mod stack;
1315pub mod system;
+41
src/reftable/reftable_basics.rs
···11+use std::ffi::{c_char, c_uchar};
22+33+/* A buffer that contains arbitrary byte slices. */
44+type ReftableBuf = Vec<c_char>;
55+66+/*
77+ * Hash functions understood by the reftable library. Note that the values are
88+ * arbitrary and somewhat random such that we can easily detect cases where the
99+ * hash hasn't been properly set up.
1010+ */
1111+enum ReftableHash {
1212+ ReftableHashSha1 = 89,
1313+ ReftableHashSha256 = 247,
1414+}
1515+1616+const REFTABLE_HASH_SIZE_SHA1: usize = 20;
1717+const REFTABLE_HASH_SIZE_SHA256: usize = 32;
1818+const REFTABLE_HASH_SIZE_MAX: usize = REFTABLE_HASH_SIZE_SHA256;
1919+2020+pub struct ReftableWrappedHash {
2121+ value: [c_uchar; REFTABLE_HASH_SIZE_MAX],
2222+} // Wrapper created so we can implement things like PartialEq on this...
2323+2424+impl PartialEq<Self> for ReftableWrappedHash {
2525+ fn eq(&self, other: &Self) -> bool {
2626+ self.value.len() == other.value.len()
2727+ && self
2828+ .value
2929+ .iter()
3030+ .zip(other.value.iter())
3131+ .all(|(self_byte, other_byte)| self_byte == other_byte)
3232+ }
3333+}
3434+3535+impl From<[c_uchar; REFTABLE_HASH_SIZE_MAX]> for ReftableWrappedHash {
3636+ fn from(value: [c_uchar; REFTABLE_HASH_SIZE_MAX]) -> Self {
3737+ ReftableWrappedHash { value }
3838+ }
3939+}
4040+4141+// FIXME: removed reftable_set_alloc ... used only for C memory management