From 465f2ff0d8fb69e0ffacb90f5ecf55370c6df09c Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Fri, 28 Apr 2023 10:46:52 -0600 Subject: [PATCH] Add a blanket implementation of ShardStore for mutable references to ShardStores. --- shardtree/src/lib.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/shardtree/src/lib.rs b/shardtree/src/lib.rs index 8d5f8bd..daa8c80 100644 --- a/shardtree/src/lib.rs +++ b/shardtree/src/lib.rs @@ -1476,6 +1476,29 @@ pub struct ShardTree, const DEPTH: u8, const SHARD_H _hash_type: PhantomData, } +impl> ShardStore for &mut S { + type Error = S::Error; + fn get_shard(&self, shard_root: Address) -> Option<&LocatedPrunableTree> { + S::get_shard(*self, shard_root) + } + + fn last_shard(&self) -> Option<&LocatedPrunableTree> { + S::last_shard(*self) + } + + fn put_shard(&mut self, subtree: LocatedPrunableTree) -> Result<(), Self::Error> { + S::put_shard(*self, subtree) + } + + fn get_shard_roots(&self) -> Vec
{ + S::get_shard_roots(*self) + } + + fn truncate(&mut self, from: Address) -> Result<(), Self::Error> { + S::truncate(*self, from) + } +} + impl< H: Hashable + Clone + PartialEq, C: Clone + Ord,