Skip to content

Commit

Permalink
impl write methods for StoreHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
miraclx committed Jun 26, 2024
1 parent d709351 commit 459efd4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/store/src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,19 @@ impl<'k, L: ReadLayer<'k>> StoreHandle<L> {
Ok(self.inner.iter(start.key())?.structured_value())
}
}

impl<'k, 'v, L: WriteLayer<'k, 'v>> StoreHandle<L> {
pub fn put<E: Entry>(
&mut self,
entry: &'k E,
value: &'v E::DataType,
) -> Result<(), Error<E::DataType>> {
self.inner
.put(entry.key(), value.as_slice().map_err(Error::CodecError)?)
.map_err(Error::LayerError)
}

pub fn delete<E: Entry>(&mut self, entry: &'k E) -> Result<(), Error<E::DataType>> {
self.inner.delete(entry.key()).map_err(Error::LayerError)
}
}

0 comments on commit 459efd4

Please sign in to comment.