rkv icon indicating copy to clipboard operation
rkv copied to clipboard

Expose NotFound as a specific StoreError

Open rnewman opened this issue 5 years ago • 1 comments

At present a missing key in a .delete call returns StoreError::LmdbError(lmdb::error::Error::NotFound). It is necessary to handle this case specifically in order to implement delete-if-present, which means that consumers need to take a dependency on lmdb-rkv.

One solution for this is to handle NotFound specially in rkv's own interface. I'm open to other suggestions.

rnewman avatar Dec 18 '19 20:12 rnewman

+1. I'd go so far as to say that delete-if-present is the semantics almost everybody wants, and trying to delete a non-existent key should not be considered an error. I propose changing the return type of .delete() to be Result<bool, StoreError>, where the Ok variant is true if the key existed and false if it didn't.

dfoxfranke avatar Dec 24 '19 20:12 dfoxfranke