diff options
Diffstat (limited to 'src/db/lib.rs')
-rw-r--r-- | src/db/lib.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/db/lib.rs b/src/db/lib.rs index 1b31df43..045c16c5 100644 --- a/src/db/lib.rs +++ b/src/db/lib.rs @@ -226,6 +226,15 @@ impl Tree { self.0.len(self.1) } + pub fn first(&self) -> Result<Option<(Value<'_>, Value<'_>)>> { + self.iter()?.next().transpose() + } + pub fn get_gt<T: AsRef<[u8]>>(&self, from: T) -> Result<Option<(Value<'_>, Value<'_>)>> { + self.range((Bound::Excluded(from), Bound::Unbounded))? + .next() + .transpose() + } + pub fn insert<T: AsRef<[u8]>, U: AsRef<[u8]>>(&self, key: T, value: U) -> Result<()> { self.0.insert(self.1, key.as_ref(), value.as_ref()) } |