khonsulabs / bonsaidb

A developer-friendly document database that grows with you, written in Rust
https://bonsaidb.io/
Apache License 2.0
998 stars 37 forks source link

CollectionDocument should support borrowing #298

Open ecton opened 1 year ago

ecton commented 1 year ago

After #284, the next location to investigate is allowing SerializedCollection to have a generic associated lifetime that CollectionDocument can utilize during the map/reduce workflows. The goal would be to allow for borrowing things like string slices from the original document data, when possible.

This causes other lifetime issues, specifically for taking a lifetime-annotated type and converting it to a 'static lifetime. This will likely need a new trait, because ToOwned introduces the Borrow restriction on its associated type. This also means that we will need another derive or add support for deriving this other trait in our Collection derive.

I've attempted tackling this a few times, but this is a very gnarly problem. I think it's doable, but I'm no longer targeting it for v0.5.