Document Rust binding recovery and remove temp snapshots
This commit is contained in:
@@ -37,6 +37,38 @@
|
||||
2. 不允许对该目录执行 `rustfmt`,避免把 CLI 原始输出改写成额外格式化噪音。
|
||||
3. `src/lib.rs` 已通过 `#[rustfmt::skip] pub mod module_bindings;` 显式阻止 workspace 级 `cargo fmt` 继续递归格式化该目录。
|
||||
|
||||
### 2.1.1 绑定缺文件恢复流程
|
||||
|
||||
若 `mod.rs` 已声明 `*_table` 模块,但目录内缺少对应 `*_table.rs` 文件,说明 Rust bindings 刷新不完整。不要手工补 generated code,统一在仓库根目录执行:
|
||||
|
||||
```powershell
|
||||
spacetime generate --no-config --lang rust --include-private --out-dir .\server-rs\crates\spacetime-client\src\module_bindings --module-path .\server-rs\crates\spacetime-module --yes
|
||||
```
|
||||
|
||||
这里必须带 `--no-config`:仓库根目录的 `spacetime.json` 同时配置了 TypeScript 与 Rust 两个生成目标,直接追加 `--lang` / `--out-dir` 会触发 SpacetimeDB CLI 的多目标参数冲突。
|
||||
|
||||
生成后用以下命令确认 `mod.rs` 声明的模块都有落盘文件:
|
||||
|
||||
```powershell
|
||||
$modFile = 'server-rs\crates\spacetime-client\src\module_bindings\mod.rs'
|
||||
$dir = 'server-rs\crates\spacetime-client\src\module_bindings'
|
||||
$mods = Select-String -Path $modFile -Pattern '^pub mod ([a-zA-Z0-9_]+);' |
|
||||
ForEach-Object { $_.Matches[0].Groups[1].Value }
|
||||
$missing = @()
|
||||
foreach ($m in $mods) {
|
||||
if (-not (Test-Path (Join-Path $dir ($m + '.rs')))) {
|
||||
$missing += $m
|
||||
}
|
||||
}
|
||||
if ($missing.Count -eq 0) { 'missing module files: 0' } else { $missing }
|
||||
```
|
||||
|
||||
最后至少执行:
|
||||
|
||||
```powershell
|
||||
cargo check -p spacetime-client --manifest-path server-rs\Cargo.toml
|
||||
```
|
||||
|
||||
## 3. 边界约束
|
||||
|
||||
1. `spacetime-client` 只承接 SpacetimeDB 客户端访问适配,不承接具体业务模块的规则实现。
|
||||
|
||||
Reference in New Issue
Block a user