Skip to content

Add option to export model keys #220

Open
@Grimeh

Description

@Grimeh

I'm restructuring my project and have noticed that model keys are defined with pub(crate) visibility.
I can see the motivation for this choice and generally agree with it. However it would be helpful to have the ability to make them pub for access from sibling crates.

From a quick look (and my limited experience with proc macros) it seems like it wouldn't be too difficult to add a parameter to the native_db macro to enable something like:

#[native_model(...)]
#[native_db(export_keys = true)]
pub struct MyTable { ... }

Then pub(crate) enum #keys_enum_name from native_db.rs:59 could be changed to something like #keys_visibility enum #keys_enum_name.

pub(crate) enum #keys_enum_name {
#(#keys_enum),*
}

I'm going to make a fork to try this out for my own purposes, would you be keen on this change if I opened a PR?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions