Skip to main content

LazyTree

Struct LazyTree 

Source
pub struct LazyTree { /* private fields */ }

Implementations§

Source§

impl LazyTree

Source

pub fn new() -> Self

Source

pub fn load(&mut self, position: Position, node: Option<TreeNode>)

読んだノードを入れる。None は、読んだらなかった。すでに持っていれば何もしない(変えたものを消さない)

Source

pub fn set_generation(&mut self, generation: u64)

これから読むか使うノードを、世代 generation で使ったことにする

Source

pub fn is_loaded(&self, position: &Position) -> bool

Source

pub fn next_on_path(&self, key: &[u8; 32]) -> Option<Position>

根から key の葉までの道で、次に読むべき位置。全部読んであれば None。足すときに食い違うところまでと、 外すときに合わせる兄弟は含まない(それは当てる途中で記録される)

Source

pub fn take_missed(&mut self) -> BTreeSet<Position>

まだ読んでいないのに要った位置

Source

pub fn set(&mut self, key: Hash256, value: Hash256)

葉を置く。同じキーがあれば値を置き換える。読んでいないノードが要ったら、記録して何もしない

Source

pub fn remove(&mut self, key: &Hash256)

葉を外す。なければ何もしない。読んでいないノードが要ったら、記録して何もしない

Source

pub fn root(&mut self) -> Hash256

根のハッシュ。空なら EMPTY_ROOT。根を読んでいなければ、記録して EMPTY_ROOT

Source

pub fn take_node_changes(&mut self) -> Vec<(Position, Option<TreeNode>)>

前に呼んでから変わったノード。位置と、今のノードか、なくなったら None。LazyTree::root のあとで呼ぶ

Source

pub fn discard_changes(&mut self)

前にノードの変化を返してから変えたノードを、変える前に戻す。保存に書かずに実行を捨てるとき

Source

pub fn forget_node_changes(&mut self)

ノードの変化を返さずに捨てる。保存にあるものと同じ木のとき

Source

pub fn evict(&mut self, capacity: usize) -> usize

読んだノードが capacity を超えていれば、根に近いノードと変わったノードのほかを、使った世代の古いほうから 捨てる。捨てた数

Source

pub fn len(&self) -> usize

読んだノードの数

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Debug for LazyTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LazyTree

Source§

fn default() -> LazyTree

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.