Merge pull request #66 from nuttycom/shardstore_blanket_mut_impl

Add a blanket implementation of ShardStore for mutable references to ShardStores
This commit is contained in:
Kris Nuttycombe 2023-05-10 20:34:49 -06:00 committed by GitHub
commit 951d61b27b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -1476,6 +1476,29 @@ pub struct ShardTree<H, C: Ord, S: ShardStore<H>, const DEPTH: u8, const SHARD_H
_hash_type: PhantomData<H>,
}
impl<H, S: ShardStore<H>> ShardStore<H> for &mut S {
type Error = S::Error;
fn get_shard(&self, shard_root: Address) -> Option<&LocatedPrunableTree<H>> {
S::get_shard(*self, shard_root)
}
fn last_shard(&self) -> Option<&LocatedPrunableTree<H>> {
S::last_shard(*self)
}
fn put_shard(&mut self, subtree: LocatedPrunableTree<H>) -> Result<(), Self::Error> {
S::put_shard(*self, subtree)
}
fn get_shard_roots(&self) -> Vec<Address> {
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,