More granular table traits#4775
Conversation
|
I see the Discord thread, but could you expand on what the motivation for this is in the PR description? An example of what this enables would be helpful. |
Updated 😄 |
|
Is there any way to support this functionality without a breaking change? We only do breaking changes at major version boundaries. |
@cloutiertyler I think the new version should work without breaking changes b/c its only adding new capability traits instead of basing the previous table traits off of them. |
|
Is there anything I can do to help get this through the door? Any issues or concerns I can address? I normally wouldn't make a stink of waiting for a review but it has been over 2 months now 😅 |
gefjon
left a comment
There was a problem hiding this comment.
This seems reasonable. Sorry for the long delay on review; I've been on vacation for a bit.
Description of Changes
Refactored the Rust SDK table trait surface into composable capabilities and updated Rust codegen to match. Discord thread
Motivation
The granular traits are a useful type-system cleanup on their own, but the main motivation is to let downstream integration crates like bevy_stdb express callback capabilities more directly instead of routing them through broader semantic categories.
For example,
bevy_stdbmay want to support bindings like “forward only inserts from this subscribed view as Bevy messages” for a relation that is not semantically anEventTable. Today this can still be made to work with broader abstractions, so this is not primarily about enabling new runtime behavior. The value is mostly at compile time: more precise trait bounds, clearer downstream APIs, and better guarantees that a binding only requires the capabilities it actually uses.Concretely, this makes it easier for integration crates to model things like insert-only or delete-only bindings for ordinary tables or views without conflating those behaviors with
EventTablesemantics.Example:
Summary
TableLiketrait for common table handle functionality:RowEventContextcountiterWithInsertWithDeleteWithUpdateAPI and ABI breaking changes
None. This is additive only.
Expected complexity level and risk
2/5
This is additive but potential risks/complexity are that the surface area of the API is larger and there isn't really overlap between original approach and the additive. So maybe in usage we'll need to consider satisfying those new traits too?
Testing
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