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
Add derive macro for View #139
Comments
I you propose some attributes and implementation details, I'll implement the macro. |
Yes, please! #[derive(View)]
#[view(collection(CollectionType), key(KeyType), value(ValueType), name = "by-name", version = 0)]
struct MyView; impl View for MyView {
type Collection = CollectionType;
type Key = KeyType;
type Value = ValueType;
fn name(&self) -> Name {
Name::new("by-name")
}
fn version(&self) -> u64 {
0
}
}
|
bonsaidb/crates/bonsaidb-core/src/schema/view.rs Lines 60 to 126 in aad8650
It seems that version is in |
You're right, I typed that example from memory and I forgot what was where. Version is indeed for the schema portion of the trait. ViewSchema I don't think will be derivable. We may want some sort of DSL-like macro to cut down some boilerplate, but I'll put in another issue to ponder that idea. |
So what is the state here, should this be closed? did you create a new issue for:
|
Well, funny enough last night I realized I need to move version back to View. But regardless, the macro can be implemented as-is without the version argument if it's not back on View at the time of implementation. |
Yeah, and adding the version in is a 2-minute change, that anyone could quickly do! |
I'm going to go ahead and consider this fully resolved -- the other tickets can handle the other requests for new/updated macros as needed. |
Blocked by Split schema traits into metadata and implementations #99Once we split View implementations from their metadata, View could be derived in a similar fashion as #138.
The macro needs to be able to have the location of
bonsaidb_core
specified as an optional attribute. By default, it should use::bonsaidb::core
as the path to bonsaidb_core, but a user should be able to override it based on their usage. E.g.,#[view(core = bonsaidb_server::core)]
.The text was updated successfully, but these errors were encountered: