cberner / redb

An embedded key-value database in pure Rust
https://www.redb.org
Apache License 2.0
3.07k stars 137 forks source link

`AccessGuard::map`? #784

Closed dpc closed 3 months ago

dpc commented 3 months ago

IIUC, AccessGuard is lazy, and won't actually access the data until .value() is used.

If there was an:

fn map<T, F>(self, f: F) -> AccessGuardMap<T, F> where F: FnOnce(Key) -> T;

it would be possible to implement wrappers, that could return e.g. an access to a single field, or de/serialize the value in flight, etc. preserving the lazy behavior.

dpc commented 3 months ago

Well, probably possible to implement outside all the same.