mcpField
S
spacetimedb-client-rust

spacetimedb-client-rust

github.com/danmossaDevelopment2155 installsUpdated 19w ago
Repository

About spacetimedb-client-rust

A skill for implementing Rust clients with the SpacetimeDB SDK. It covers generated bindings, connection and subscription lifecycle, table callbacks, and reducer calls, while directing server-side work elsewhere.

Key features

  1. 01Generate Rust client bindings
  2. 02Configure connections and subscriptions
  3. 03Advance runtime and cache updates
  4. 04Read subscribed rows and use indexes
  5. 05Register table callbacks and call reducers

Use cases

  1. 01Build a Rust client for a SpacetimeDB module
  2. 02Handle subscriptions and table updates in a client
  3. 03Keep generated bindings aligned with a Rust project

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/danmossa/spacetimedb-skills --skill spacetimedb-client-rust

After installing, type/spacetimedb-client-rustin Claude Code to confirm it loaded.

Bundled filesreferences/clients-rust.md

Details

From the project README

Use this skill for Rust client implementation.

Core Rust patterns

Generate Rust bindings and import generated names from the local module:

spacetime generate --lang rust --out-dir client/src/module_bindings --module-path spacetimedb
use module_bindings::DbConnection;

let conn = DbConnection::builder()
    .with_uri("ws://localhost:3000")
    .with_database_name("my-database")
    .on_connect(|ctx, identity, _token| {
        log::info!("connected: {identity}");
        ctx.subscription_builder().subscribe_to_all_tables();
    })
    .on_connect_error(|_ctx, err| log::error!("connect error: {err}"))
    .on_disconnect(|_ctx, err| log::info!("disconnected: {err:?}"))
    .build()?;

conn.run_threaded();

Runtime rules

  • Advance the connection with run_threaded, run_async, or frame_tick; callbacks and cache updates require one of these.
  • Read subscribed rows through conn.db.<table>().iter(), .count(), and generated unique/index handles.
  • Register on_insert, on_delete, and on_update callbacks on generated table handles; on_update requires a primary key.
  • Use conn.reducers.<reducer>(...) or ctx.reducers() in trait-generic callback contexts.
  • Keep generated binding module names and feature flags aligned with the local project.

Reference map

NeedOpen
Rust SDK APIreferences/clients-rust.md

Guidance

  • Match generated module names and binding paths from the local project.
  • Keep connection lifecycle, subscription callbacks, and reducer calls aligned with the Rust SDK reference.
  • Route Rust server module schema or reducer code to table and reducer skills rather than this client skill.

Comments

Markdown supported