Open
Conversation
onx2
commented
Apr 10, 2026
Author
There was a problem hiding this comment.
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(),
});
});
}
onx2
commented
Apr 10, 2026
Author
There was a problem hiding this comment.
Trait changes mean we need updated codegen too (breaking).
onx2
commented
Apr 10, 2026
Comment on lines
+208
to
+209
|
|
||
| impl<'ctx> __sdk::EventTable for {table_handle}<'ctx> {{}} |
Author
There was a problem hiding this comment.
Do we need these empty impls? Maybe now Table can just be removed entirely?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Changes
This looks like a large diff but the real changes are just
sdks/rust/src/lib.rsfor traits andcrates/codegen/src/rust.rsfor the new codegen.Refactored the Rust SDK table trait surface into composable capabilities and updated Rust codegen to match. Discord thread
Summary
TableLiketrait for common table handle functionality:RowEventContextcountiterWithInsertWithDeleteWithUpdateTable: TableLike + WithInsert + WithDeleteTableWithPrimaryKey: Table + WithUpdateEventTable: TableLike + WithInsertTableLikeWithInsertWithDeleteWithUpdateTable,TableWithPrimaryKey, andEventTablespacetimedb_sdk::__codegenso generated bindings can compile correctlyAPI and ABI breaking changes
Yes — this is an API-breaking change in the Rust SDK trait hierarchy.
Notable changes:
WithInsertWithDeleteWithUpdateTable/EventTableimpl blockExpected complexity level and risk
3/5
This is a moderate refactor because it changes the Rust SDK trait model, affects Rust code generation, and requires the generated binding surface and SDK re-export surface to stay in sync.
Main interaction points:
sdks/rust/src/table.rssdks/rust/src/lib.rscrates/codegen/src/rust.rsTesting
cargo check --manifest-path /Users/onx2/Documents/projects/SpacetimeDB/sdks/rust/Cargo.tomlcargo test --manifest-path /Users/onx2/Documents/projects/SpacetimeDB/Cargo.toml -p spacetimedb-codegen test_codegen_rust