From 459efd43fe0ac0ac866b29f212bebcff4a3c4080 Mon Sep 17 00:00:00 2001 From: Miraculous Owonubi Date: Wed, 26 Jun 2024 20:00:07 +0300 Subject: [PATCH] impl write methods for StoreHandle --- crates/store/src/handle.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/store/src/handle.rs b/crates/store/src/handle.rs index aece6ad08..44be8e0b0 100644 --- a/crates/store/src/handle.rs +++ b/crates/store/src/handle.rs @@ -65,3 +65,19 @@ impl<'k, L: ReadLayer<'k>> StoreHandle { Ok(self.inner.iter(start.key())?.structured_value()) } } + +impl<'k, 'v, L: WriteLayer<'k, 'v>> StoreHandle { + pub fn put( + &mut self, + entry: &'k E, + value: &'v E::DataType, + ) -> Result<(), Error> { + self.inner + .put(entry.key(), value.as_slice().map_err(Error::CodecError)?) + .map_err(Error::LayerError) + } + + pub fn delete(&mut self, entry: &'k E) -> Result<(), Error> { + self.inner.delete(entry.key()).map_err(Error::LayerError) + } +}