Skip to content

[pull] master from clockworklabs:master#563

Merged
pull[bot] merged 2 commits into
age-rs:masterfrom
clockworklabs:master
Jul 8, 2026
Merged

[pull] master from clockworklabs:master#563
pull[bot] merged 2 commits into
age-rs:masterfrom
clockworklabs:master

Conversation

@pull

@pull pull Bot commented Jul 8, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

onx2 and others added 2 commits July 7, 2026 23:46
# Description of Changes

Adds a lifetime-aware `TableAccessor` trait to the Rust SDK and updates
Rust codegen to emit a generated accessor marker type for each table.

Generated bindings now include a marker type like:

```rust
pub struct PlayerPositionTableAccessor;

impl __sdk::TableAccessor<super::RemoteTables> for PlayerPositionTableAccessor {
    type Row = PlayerPositionRow;
    type Handle<'db> = PlayerPositionTableHandle<'db>;

    fn get<'db>(db: &'db super::RemoteTables) -> Self::Handle<'db> {
        db.player_position()
    }
}
```

The existing generated table access methods remain unchanged:
```rust
fn player_position(&self) -> PlayerPositionTableHandle<'_>;
```

## Motivation

Generated table handles are lifetime-scoped to `RemoteTables`, which
makes it difficult for downstream crates to expose ergonomic generic
APIs over generated table accessors. In particular, a method like
`RemoteTables::player_position` returns a handle whose type depends on
the borrow lifetime of `RemoteTables`, which is hard to represent in
higher-order APIs.

The existing lifetime is not mechanically required by the current handle
storage model: generated table handles own an SDK `TableHandle<Row>`,
which holds shared connection/cache state rather than borrowing from
`RemoteTables`. However, the lifetime does express the conceptual scope
of a handle relative to the database view that produced it.

This PR preserves that scoped API contract instead of removing the
lifetime, and adds a generated marker type so generic downstream APIs
can name table accessors without erasing or weakening the lifetime
relationship.


This enables APIs such as the below instead of requiring closure-based
registration everywhere which greatly simplifies downstream crate code
and consumer code.

```diff
- .add_table::<PlayerPosition>(|reg, db| reg.bind(db.player_position()))
+ .add_table::<PlayerPositionTableAccessor>()
```

# API and ABI breaking changes

None.

This is additive and should not break existing generated bindings usage.
Existing code such as the below continues to work unchanged:

```rust
ctx.db.player_position().on_insert(...)
```

The new `TableAccessor` trait is exported from both the SDK root and
`__codegen`, and generated marker types are added alongside existing
generated table handles and access traits.

# Expected complexity level and risk

Complexity: **2/5**

The change is small and additive, but it touches Rust SDK codegen and
generated binding shape. The main risk is introducing generated code
that depends on the new SDK trait, so generated bindings and the SDK
version must match.

This does not alter table handle ownership, callback behavior, or
existing access methods.

# Testing

- [x] Ran `cargo check -p spacetimedb-sdk`.
- [x] Regenerated Rust bindings for my game.
- [x] Verified generated bindings include `*TableAccessor` marker types.
- [x] Used generated accessors from downstream local `bevy_stdb`.
- [x] Ran `cargo check -p bevy_stdb` against the local SDK.

---------

Signed-off-by: Jeff Rooks <onx2rj@gmail.com>
Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
# Description of Changes
Makes `spacetimedb-dst` to `spacetimedb-dst-lib`.
To be able to write tests for private repo, We have two options:
1. Write all DST code in private.
2. Make this a `lib` with test covering public specific code, and write
a `bin` in private,


I chose option 2 as it's easier to maintain tests like this, otherwise
you may have to raise a separate PR for changes in `engine` crate, which
will be painful.



This also makes methods of `TestSuite` async.

binary crate PR -
clockworklabs/SpacetimeDBPrivate#3287


# API and ABI breaking changes
NA 

# Expected complexity level and risk
1

# Testing
Not applicable.
@pull pull Bot locked and limited conversation to collaborators Jul 8, 2026
@pull pull Bot added the ⤵️ pull label Jul 8, 2026
@pull pull Bot merged commit 173b014 into age-rs:master Jul 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants