Skip to main content

Edit

Struct Edit 

Source
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>

Source

fn new(tree: &'t Tree) -> Self

Source

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.

Source

fn store(&mut self, open: Open) -> Cid

Encodes a node and puts it in the tree.

Source

fn store_unless_empty(&mut self, open: Open) -> Option<Cid>

Self::store, or no subtree at all for a node that holds nothing.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn merge( &mut self, low: Option<Cid>, high: Option<Cid>, layer: usize, ) -> Option<Cid>

Joins two neighbouring subtrees at layer, every key of low sorting before every key of high.

Source

fn finish(self, root: Cid, layer: usize) -> Staged

Ends the edit with root at the top.

Auto Trait Implementations§

§

impl<'t> Freeze for Edit<'t>

§

impl<'t> RefUnwindSafe for Edit<'t>

§

impl<'t> Send for Edit<'t>

§

impl<'t> Sync for Edit<'t>

§

impl<'t> Unpin for Edit<'t>

§

impl<'t> UnsafeUnpin for Edit<'t>

§

impl<'t> UnwindSafe for Edit<'t>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.