(path: PathBuf)
| 21 | V: Clone + TreeSerialization + TreeDeserialization, |
| 22 | { |
| 23 | pub fn new(path: PathBuf) -> io::Result<Self> { |
| 24 | let mut storage_manager = StorageManager::<K, V>::new(path)?; |
| 25 | |
| 26 | // println!("INIT Used space: {}", storage_manager.used_space); |
| 27 | |
| 28 | if storage_manager.used_space() == 0 { |
| 29 | let root_offset: usize; |
| 30 | let mut root = Node::new_leaf(0); |
| 31 | root.is_root = true; |
| 32 | root_offset = storage_manager.store_node(&mut root)?; |
| 33 | storage_manager.set_root_offset(root_offset); |
| 34 | // println!("Initialized from scratch with Root offset: {}", root_offset); |
| 35 | } |
| 36 | |
| 37 | Ok(Tree { |
| 38 | storage_manager, |
| 39 | b: 32, |
| 40 | }) |
| 41 | } |
| 42 | |
| 43 | pub fn insert(&mut self, key: K, value: V) -> Result<(), io::Error> { |
| 44 | // println!("Inserting key: {}, value: {}", key, value); |
nothing calls this directly
no test coverage detected