Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supply dynamic database object #255

Open
FlixCoder opened this issue May 28, 2022 · 2 comments
Open

Supply dynamic database object #255

FlixCoder opened this issue May 28, 2022 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@FlixCoder
Copy link

Hi!

Thank you for the great work on bonsaidb, it is a really nice project!

While working with it, I stumbled upon the following issue: Making a library for any database via the AsyncConnection trait is easy with generics. However, keeping those generics everywhere forces me to forward these to the library user as well in some types, making it unwieldy to use. I would like to have a dyn AsyncConnection object, but it forces me to specify the storage object as well, which I am unsure how to do and whether it is possible to be compatible with bonsaidb at the same time.

It would be great if there would be some enum that wraps all database types, which one can use internally without generics. Is there anything I missed, that I can use right now?

Thank you in advance!

@ecton ecton added the enhancement New feature or request label May 28, 2022
@ecton ecton added this to the v0.5.0 milestone May 28, 2022
@ecton
Copy link
Member

ecton commented May 28, 2022

Thank you for the feedback!

I started down an enum path already, but I don't think it's the right design decision. I think I need to come up with a way to Box dyn [Async]Connecitons instead -- but with all of the generic usage, that will be a little bit of a challenge.

@ecton
Copy link
Member

ecton commented Feb 28, 2023

I worked on this over yesterday and today, but it's a lot harder than it might seem at first glance. This is due to all the generic functions not being trait-object safe. That being said, it looks completely feasible to come up with a way to use methods like SerializedCollection::get and pass an &dyn Connection to it.

The amount of work required, though, is quite significant, and it introduces fun naming challenges. I'm going to move this from the next milestone, but I do want to add this someday.

@ecton ecton modified the milestones: v0.5.0, v1.0 Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants