1pub mod bytes;
20pub mod codec;
21pub(crate) mod cursor;
22pub(crate) mod index;
23pub(crate) mod node;
24pub(crate) mod tree;
25pub mod typed;
26pub(crate) mod value_store;
27
28pub use crate::storage::{JournalMode, PageId, PagerIntegrityReport};
29pub(crate) use bytes::ByteTreeStoreSnapshot;
30pub use bytes::{ByteTree, ByteTreeCursor, ByteTreeStore};
31pub use codec::{KeyValueCodec, RawBytesCodec};
32pub use tree::TreeSpaceStats;
33pub use typed::{TypedTree, TypedTreeCursor, TypedTreeStore};
34
35pub const BTREE_ORDER: usize = 100;
36
37#[derive(Debug, Clone, Copy, PartialEq, Eq)]
38pub enum NodeType {
39 Internal,
40 Leaf,
41}
42
43#[derive(Debug, Clone)]
44pub struct BTreeKey {
45 pub data: Vec<u8>,
46}
47
48impl BTreeKey {
49 pub fn new(data: Vec<u8>) -> Self {
50 Self { data }
51 }
52
53 pub fn as_bytes(&self) -> &[u8] {
54 &self.data
55 }
56}
57
58impl PartialEq for BTreeKey {
59 fn eq(&self, other: &Self) -> bool {
60 self.data == other.data
61 }
62}
63
64impl Eq for BTreeKey {}
65
66impl PartialOrd for BTreeKey {
67 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
68 Some(self.cmp(other))
69 }
70}
71
72impl Ord for BTreeKey {
73 fn cmp(&self, other: &Self) -> std::cmp::Ordering {
74 self.data.cmp(&other.data)
75 }
76}
77
78#[derive(Debug, Clone, PartialEq)]
79pub struct BTreeValue {
80 pub data: Vec<u8>,
81}
82
83impl BTreeValue {
84 pub fn new(data: Vec<u8>) -> Self {
85 Self { data }
86 }
87
88 pub fn as_bytes(&self) -> &[u8] {
89 &self.data
90 }
91}
92
93#[cfg(test)]
94mod tests;