Skip to content

Table accessor + capabilities trait - #85

Merged
onx2 merged 3 commits into
mainfrom
table-accessor
Aug 14, 2026
Merged

Table accessor + capabilities trait#85
onx2 merged 3 commits into
mainfrom
table-accessor

Conversation

@onx2

@onx2 onx2 commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Summary

Update bevy_stdb to use SpacetimeDB's generated TableAccessor markers and granular table capability traits.

Table registration no longer requires a lifetime-sensitive callback:

- .add_table::<Player>(|reg, db| reg.bind(db.player()))
+ .add_table::<PlayerTableAccessor>()

Binding internals now use the precise SDK capabilities:

  • TableLike
  • WithInsert
  • WithDelete
  • WithUpdate

This removes the need to rely on broader semantic traits such as Table, TableWithPrimaryKey, and EventTable.

The result is simpler registration, better lifetime handling, and more precise compile-time guarantees. For example, insert-only sources only require WithInsert, while update bindings require WithUpdate explicitly. Views with primary keys can therefore support updates when their generated handle provides that capability.

@onx2 onx2 self-assigned this Aug 14, 2026
@onx2 onx2 added the enhancement New feature or request label Aug 14, 2026
@onx2
onx2 marked this pull request as ready for review August 14, 2026 00:59
@onx2
onx2 requested a lite review from Copilot August 14, 2026 00:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors table binding/registration to use SpacetimeDB SDK “table accessor + capability traits” (e.g., TableAccessor, TableLike, WithInsert/WithDelete/WithUpdate), replacing the previous binder-struct API and updating documentation/examples accordingly.

Changes:

  • Replace TableBinder/ViewBinder/etc. with capability-based binding helpers (bind_table, bind_table_without_pk, bind_insert).
  • Update StdbPlugin builder methods to register tables/views/event tables via generated *TableAccessor marker types.
  • Bump bevy_stdb to 0.13.0, update SpacetimeDB dependency versions, and refresh the example bindings/lockfiles.

Reviewed changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/table/mod.rs Switches table module exports to the new bind helper functions.
src/table/bind.rs Implements capability-trait-based binding helpers for insert/delete/update/insert-update.
src/plugin.rs Updates StdbPlugin table/view/event-table registration API to use TableAccessor + capability bounds.
src/lib.rs Updates crate-level docs to reflect the new accessor-based API.
README.md Updates usage examples and explanation text for accessor-based registration.
examples/simple/server/Cargo.toml Updates SpacetimeDB server dependency requirement.
examples/simple/client/src/stdb.rs Updates example client to register a table via *TableAccessor.
examples/simple/client/src/module_bindings/player_table.rs Adds generated TableAccessor + TableLike + capability trait impls for the player table handle.
examples/simple/client/src/module_bindings/mod.rs Updates generated-by SpacetimeDB CLI version comment.
examples/simple/client/Cargo.toml Updates spacetimedb-sdk dependency version (including wasm target dep).
examples/simple/Cargo.lock Updates example lockfile versions for the new dependency set.
Cargo.toml Bumps crate version and updates spacetimedb-sdk dependency requirement.
Cargo.lock Updates lockfile to bevy_stdb 0.13.0 and newer SpacetimeDB-related crates.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@onx2
onx2 merged commit 7d75e9f into main Aug 14, 2026
11 checks passed
@onx2
onx2 deleted the table-accessor branch August 14, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use table accessor trait when available More precise bind_<insert/update/delete/insert_update> trait bounds

2 participants