pub struct LazyTree { /* private fields */ }Implementations§
Source§impl LazyTree
impl LazyTree
pub fn new() -> Self
Sourcepub fn load(&mut self, position: Position, node: Option<TreeNode>)
pub fn load(&mut self, position: Position, node: Option<TreeNode>)
読んだノードを入れる。None は、読んだらなかった。すでに持っていれば何もしない(変えたものを消さない)
Sourcepub fn set_generation(&mut self, generation: u64)
pub fn set_generation(&mut self, generation: u64)
これから読むか使うノードを、世代 generation で使ったことにする
pub fn is_loaded(&self, position: &Position) -> bool
Sourcepub fn next_on_path(&self, key: &[u8; 32]) -> Option<Position>
pub fn next_on_path(&self, key: &[u8; 32]) -> Option<Position>
根から key の葉までの道で、次に読むべき位置。全部読んであれば None。足すときに食い違うところまでと、
外すときに合わせる兄弟は含まない(それは当てる途中で記録される)
Sourcepub fn take_missed(&mut self) -> BTreeSet<Position>
pub fn take_missed(&mut self) -> BTreeSet<Position>
まだ読んでいないのに要った位置
Sourcepub fn set(&mut self, key: Hash256, value: Hash256)
pub fn set(&mut self, key: Hash256, value: Hash256)
葉を置く。同じキーがあれば値を置き換える。読んでいないノードが要ったら、記録して何もしない
Sourcepub fn root(&mut self) -> Hash256
pub fn root(&mut self) -> Hash256
根のハッシュ。空なら EMPTY_ROOT。根を読んでいなければ、記録して EMPTY_ROOT
Sourcepub fn take_node_changes(&mut self) -> Vec<(Position, Option<TreeNode>)>
pub fn take_node_changes(&mut self) -> Vec<(Position, Option<TreeNode>)>
前に呼んでから変わったノード。位置と、今のノードか、なくなったら None。LazyTree::root のあとで呼ぶ
Sourcepub fn discard_changes(&mut self)
pub fn discard_changes(&mut self)
前にノードの変化を返してから変えたノードを、変える前に戻す。保存に書かずに実行を捨てるとき
Sourcepub fn forget_node_changes(&mut self)
pub fn forget_node_changes(&mut self)
ノードの変化を返さずに捨てる。保存にあるものと同じ木のとき
Sourcepub fn evict(&mut self, capacity: usize) -> usize
pub fn evict(&mut self, capacity: usize) -> usize
読んだノードが capacity を超えていれば、根に近いノードと変わったノードのほかを、使った世代の古いほうから
捨てる。捨てた数
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LazyTree
impl RefUnwindSafe for LazyTree
impl Send for LazyTree
impl Sync for LazyTree
impl Unpin for LazyTree
impl UnsafeUnpin for LazyTree
impl UnwindSafe for LazyTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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