DEV Community

elrafoon
elrafoon

Posted on

Generic algorithms on top of redb database

Hi, I need help with implementing some generic algorithms in rust on top of redb database tables.

I have a redb database with 2 tables (but there will be more) and I need to be able to use the same algorithms on all tables.

Each redb table has wrapper struct implemented - NodeTable and FWUStateTable. To allow generic programming of the algorithms, I declared a few traits - TableOps, DatabaseTable, TableKey - and tried to implement the algorithms as TableOps functions.

But after 3 days, I still can't get generic types and lifetimes right, there is simply too much of them and they don't play together.

Subjectively there is also too many bounds defined on trait TableOps, and I suspect I do something totally wrong.

Could someone look at the repo here:

https://github.com/elrafoon/ptnet-mgr/tree/master/ptnet-mgrd/src/database

and give me some advice?

I'm a quite new to rust....

Thanks!

Top comments (0)