struct Edit<'t> {
tree: &'t Tree,
written: BTreeMap<Cid, (Node, Vec<u8>)>,
present: BTreeMap<Cid, bool>,
}Expand description
An edit in progress: the tree as it was, and what the edit has done.
Fields§
§tree: &'t Tree§written: BTreeMap<Cid, (Node, Vec<u8>)>Every node the edit has stored, by CID, with its block.
present: BTreeMap<Cid, bool>Whether each node the edit touched is in the tree once it is done.
Opening a node takes it out and storing one puts it in, in the order they happen. A node taken out and then stored again identically is still there, which is what an edit that changes nothing amounts to.
Implementations§
Source§impl<'t> Edit<'t>
impl<'t> Edit<'t>
fn new(tree: &'t Tree) -> Self
Sourcefn open(&mut self, cid: &Cid) -> Open
fn open(&mut self, cid: &Cid) -> Open
Takes a node out of the tree to be rewritten.
§Panics
If the tree links to a node it does not hold. Every link in a tree names a node the same tree stored, and nothing outside this module can change the nodes a tree holds.
Sourcefn store_unless_empty(&mut self, open: Open) -> Option<Cid>
fn store_unless_empty(&mut self, open: Open) -> Option<Cid>
Self::store, or no subtree at all for a node that holds nothing.
Sourcefn insert(
&mut self,
node: Open,
layer: usize,
key: &[u8],
value: Cid,
height: usize,
) -> Open
fn insert( &mut self, node: Open, layer: usize, key: &[u8], value: Cid, height: usize, ) -> Open
Puts key into the node at layer, and answers the node.
Sourcefn split(
&mut self,
subtree: Option<Cid>,
layer: usize,
key: &[u8],
) -> (Option<Cid>, Option<Cid>)
fn split( &mut self, subtree: Option<Cid>, layer: usize, key: &[u8], ) -> (Option<Cid>, Option<Cid>)
Cuts the subtree at layer into the keys before key and the keys
after it. key is taller than layer, so no entry here is key.
Sourcefn lift(&mut self, subtree: Option<Cid>, from: usize, to: usize) -> Option<Cid>
fn lift(&mut self, subtree: Option<Cid>, from: usize, to: usize) -> Option<Cid>
Hangs a subtree at from under entry-less nodes until it sits at to.
Sourcefn remove(
&mut self,
node: Open,
layer: usize,
key: &[u8],
height: usize,
) -> Open
fn remove( &mut self, node: Open, layer: usize, key: &[u8], height: usize, ) -> Open
Takes key out of the node at layer, and answers the node.
The caller has established that the tree holds key.