用途:面向 SpacetimeDB 的 Rust 客户端实现,覆盖生成绑定、连接、订阅、缓存读取、reducer 调用与回调等场景。
主要能力:生成 Rust 绑定并导入本地模块中的生成名称,常用命令为:spacetime generate --lang rust --out-dir client/src/module_bindings --module-path spacetimedb。连接侧使用 DbConnection.builder(),可配置 with_uri、with_database_name,并挂载 on_connect、on_connect_error、on_disconnect;在 on_connect 中可通过 ctx.subscription_builder().subscribe_to_all_tables() 订阅全部表。运行时需用 run_threaded、run_async 或 frame_tick 推进连接,否则回调与缓存更新不会生效。缓存读取通过 conn.db.<table>().iter()、.count() 及生成的唯一/索引句柄完成;可在生成的表句柄上注册 on_insert、on_delete、on_update,其中 on_update 需要主键。调用 reducer 使用 conn.reducers.<reducer>(...),在 trait 泛型回调上下文中用 ctx.reducers()。
使用方式与限制:保持生成绑定模块名和 feature flag 与本地工程一致,模块名和绑定路径以本地项目为准;参考 Rust SDK 文档 references/clients-rust.md。连接生命周期、订阅回调与 reducer 调用需与该 Rust SDK 参考保持一致。Rust 服务端模块 schema 或 reducer 代码不属于本技能,应交给 table 与 reducer 相关技能。官方资料未提供版本、平台与收费信息。