diff options
author | Alex Auvolat <alex@adnab.me> | 2022-06-08 17:49:36 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-06-08 17:49:36 +0200 |
commit | ab374e71787b1da37e1f885e88090bbcbd53ec47 (patch) | |
tree | 7863a488fdb9acf9d198fb992b34b67ca42f5f26 /src/db/lib.rs | |
parent | f8a6fff2b7bb754fa315e1c00b0f6adea4586fa8 (diff) | |
download | garage-ab374e71787b1da37e1f885e88090bbcbd53ec47.tar.gz garage-ab374e71787b1da37e1f885e88090bbcbd53ec47.zip |
Add .clear() on db trees
Diffstat (limited to 'src/db/lib.rs')
-rw-r--r-- | src/db/lib.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/db/lib.rs b/src/db/lib.rs index e9d3ea18..8188c715 100644 --- a/src/db/lib.rs +++ b/src/db/lib.rs @@ -197,6 +197,11 @@ impl Tree { pub fn remove<T: AsRef<[u8]>>(&self, key: T) -> Result<Option<Value>> { self.0.remove(self.1, key.as_ref()) } + /// Clears all values from the tree + #[inline] + pub fn clear(&self) -> Result<()> { + self.0.clear(self.1) + } #[inline] pub fn iter(&self) -> Result<ValueIter<'_>> { @@ -311,6 +316,7 @@ pub(crate) trait IDb: Send + Sync { fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<Option<Value>>; fn remove(&self, tree: usize, key: &[u8]) -> Result<Option<Value>>; + fn clear(&self, tree: usize) -> Result<()>; fn iter(&self, tree: usize) -> Result<ValueIter<'_>>; fn iter_rev(&self, tree: usize) -> Result<ValueIter<'_>>; |