-
Notifications
You must be signed in to change notification settings - Fork 989
More granular table traits #4775
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,13 +183,15 @@ pub struct {insert_callback_id}(__sdk::CallbackId); | |
| write!( | ||
| out, | ||
| " | ||
| impl<'ctx> __sdk::EventTable for {table_handle}<'ctx> {{ | ||
| impl<'ctx> __sdk::TableLike for {table_handle}<'ctx> {{ | ||
| type Row = {row_type}; | ||
| type EventContext = super::EventContext; | ||
|
|
||
| fn count(&self) -> u64 {{ self.imp.count() }} | ||
| fn iter(&self) -> impl Iterator<Item = {row_type}> + '_ {{ self.imp.iter() }} | ||
| }} | ||
|
|
||
| impl<'ctx> __sdk::WithInsert for {table_handle}<'ctx> {{ | ||
| type InsertCallbackId = {insert_callback_id}; | ||
|
|
||
| fn on_insert( | ||
|
|
@@ -203,6 +205,8 @@ impl<'ctx> __sdk::EventTable for {table_handle}<'ctx> {{ | |
| self.imp.remove_on_insert(callback.0) | ||
| }} | ||
| }} | ||
|
|
||
| impl<'ctx> __sdk::EventTable for {table_handle}<'ctx> {{}} | ||
|
Comment on lines
+208
to
+209
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need these empty impls? Maybe now Table can just be removed entirely? |
||
| " | ||
| ); | ||
| } else { | ||
|
|
@@ -213,13 +217,15 @@ impl<'ctx> __sdk::EventTable for {table_handle}<'ctx> {{ | |
| out, | ||
| "pub struct {delete_callback_id}(__sdk::CallbackId); | ||
|
|
||
| impl<'ctx> __sdk::Table for {table_handle}<'ctx> {{ | ||
| impl<'ctx> __sdk::TableLike for {table_handle}<'ctx> {{ | ||
| type Row = {row_type}; | ||
| type EventContext = super::EventContext; | ||
|
|
||
| fn count(&self) -> u64 {{ self.imp.count() }} | ||
| fn iter(&self) -> impl Iterator<Item = {row_type}> + '_ {{ self.imp.iter() }} | ||
| }} | ||
|
|
||
| impl<'ctx> __sdk::WithInsert for {table_handle}<'ctx> {{ | ||
| type InsertCallbackId = {insert_callback_id}; | ||
|
|
||
| fn on_insert( | ||
|
|
@@ -232,7 +238,9 @@ impl<'ctx> __sdk::Table for {table_handle}<'ctx> {{ | |
| fn remove_on_insert(&self, callback: {insert_callback_id}) {{ | ||
| self.imp.remove_on_insert(callback.0) | ||
| }} | ||
| }} | ||
|
|
||
| impl<'ctx> __sdk::WithDelete for {table_handle}<'ctx> {{ | ||
| type DeleteCallbackId = {delete_callback_id}; | ||
|
|
||
| fn on_delete( | ||
|
|
@@ -246,6 +254,8 @@ impl<'ctx> __sdk::Table for {table_handle}<'ctx> {{ | |
| self.imp.remove_on_delete(callback.0) | ||
| }} | ||
| }} | ||
|
|
||
| impl<'ctx> __sdk::Table for {table_handle}<'ctx> {{}} | ||
| " | ||
| ); | ||
|
|
||
|
|
@@ -258,7 +268,7 @@ impl<'ctx> __sdk::Table for {table_handle}<'ctx> {{ | |
| " | ||
| pub struct {update_callback_id}(__sdk::CallbackId); | ||
|
|
||
| impl<'ctx> __sdk::TableWithPrimaryKey for {table_handle}<'ctx> {{ | ||
| impl<'ctx> __sdk::WithUpdate for {table_handle}<'ctx> {{ | ||
| type UpdateCallbackId = {update_callback_id}; | ||
|
|
||
| fn on_update( | ||
|
|
@@ -272,6 +282,8 @@ impl<'ctx> __sdk::TableWithPrimaryKey for {table_handle}<'ctx> {{ | |
| self.imp.remove_on_update(callback.0) | ||
| }} | ||
| }} | ||
|
|
||
| impl<'ctx> __sdk::TableWithPrimaryKey for {table_handle}<'ctx> {{}} | ||
| " | ||
| ); | ||
| } | ||
|
|
@@ -1877,7 +1889,7 @@ impl<Ctx: __sdk::DbContext< | |
| out, | ||
| "EventContext", | ||
| Some("__sdk::Event<Reducer>"), | ||
| "[`__sdk::Table::on_insert`], [`__sdk::Table::on_delete`] and [`__sdk::TableWithPrimaryKey::on_update`] callbacks", | ||
| "[`__sdk::WithInsert::on_insert`], [`__sdk::WithDelete::on_delete`] and [`__sdk::WithUpdate::on_update`] callbacks", | ||
| Some("[`__sdk::Event`]"), | ||
| ); | ||
|
|
||
|
|
||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the main change to functionality. I wanted to have access to specific traits so in bevy_stdb I can go from: Before/after fn bind_insert<TRow, TTable>(world: &World, table: &TTable)
where
TRow: Send + Sync + Clone + InModule + 'static,
RowEvent<TRow>: Send + Sync,
- TTable: Table<
+ TTable: WithInsert<
Row = TRow,
EventContext = <<TRow as InModule>::Module as SpacetimeModule>::EventContext,
>,
TTable::EventContext: AbstractEventContext<Event = RowEvent<TRow>>,
{
let sender = channel_sender::<InsertMessage<TRow>>(world);
table.on_insert(move |ctx, row| {
let _ = sender.send(InsertMessage {
event: ctx.event().clone(),
row: row.clone(),
});
});
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trait changes mean we need updated codegen too (breaking).