Skip to content

Is it possible to create a generic wrapper struct ? #268

@lazybilly

Description

@lazybilly

Hi !

Thank you for this library, it looks great but I'm no Rust expert and I really struggle its lifetimes and creating a struct wrapper around it.

Is it actually possible to have a generic struct owning the env, wtxn and database ?

Like so:

pub struct Database<'p, Key, Value>
where
    Key: Ord + Clone + Debug + ?Sized + 'static,
    Value: PartialEq + 'static,
{
    env: Env,
    wtxn: RwTxn<'p>,
    db: Database<Key, Value>
}

The use case is that I have a lot of little databases with a ton of data spread among them and having to manage all env/wtxn is quite complicated and kind of messy (again I'm not a rust expert). It would really be much nicer in a nice wrapper which is possible with many other databases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions