aboutsummaryrefslogtreecommitdiff
path: root/src/db/lib.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-03-08 16:02:58 +0100
committerAlex Auvolat <alex@adnab.me>2024-03-08 16:02:58 +0100
commit66c23890c1a6e73fd6c5246642e087cd2866451e (patch)
treed26a7d98f8e23497419b675f6689c348fafe2de4 /src/db/lib.rs
parent05c92204ecab87540806073ac4deedfd58519240 (diff)
downloadgarage-66c23890c1a6e73fd6c5246642e087cd2866451e.tar.gz
garage-66c23890c1a6e73fd6c5246642e087cd2866451e.zip
[rm-sled] Implement some missing functionality in garage_db
Diffstat (limited to 'src/db/lib.rs')
-rw-r--r--src/db/lib.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/db/lib.rs b/src/db/lib.rs
index e81c712c..5881954d 100644
--- a/src/db/lib.rs
+++ b/src/db/lib.rs
@@ -274,6 +274,11 @@ impl<'a> Transaction<'a> {
pub fn remove<T: AsRef<[u8]>>(&mut self, tree: &Tree, key: T) -> TxOpResult<Option<Value>> {
self.tx.remove(tree.1, key.as_ref())
}
+ /// Clears all values in a tree
+ #[inline]
+ pub fn clear(&mut self, tree: &Tree) -> TxOpResult<()> {
+ self.tx.clear(tree.1)
+ }
#[inline]
pub fn iter(&self, tree: &Tree) -> TxOpResult<TxValueIter<'_>> {
@@ -350,6 +355,7 @@ pub(crate) trait ITx {
fn insert(&mut self, tree: usize, key: &[u8], value: &[u8]) -> TxOpResult<Option<Value>>;
fn remove(&mut self, tree: usize, key: &[u8]) -> TxOpResult<Option<Value>>;
+ fn clear(&mut self, tree: usize) -> TxOpResult<()>;
fn iter(&self, tree: usize) -> TxOpResult<TxValueIter<'_>>;
fn iter_rev(&self, tree: usize) -> TxOpResult<TxValueIter<'_>>;