mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-11 10:29:21 -04:00
52b6c66fa1
# Description of Changes This adds C++ server bindings (/crate/bindings-cpp) to allow writing C++ 20 modules. - Emscripten WASM build system integration with CMake - Macro-based code generation (SPACETIMEDB_TABLE, SPACETIMEDB_REDUCER, etc) - All SpacetimeDB types supported (primitives, Timestamp, Identity, Uuid, etc) - Product types via SPACETIMEDB_STRUCT - Sum types via SPACETIMEDB_ENUM - Constraints marked with FIELD* macros # API and ABI breaking changes None # Expected complexity level and risk 2 - Doesn't heavily impact any other areas but is complex macro C++ structure to support a similar developer experience, did have a small impact on init command # Testing - [x] modules/module-test-cpp - heavily tested every reducer - [x] modules/benchmarks-cpp - tested through the standalone (~6x faster than C#, ~6x slower than Rust) - [x] modules/sdk-test-cpp - [x] modules/sdk-test-procedure-cpp - [x] modules/sdk-test-view-cpp - [x] Wrote several test modules myself - [x] Quickstart smoketest [Currently in progress] - [ ] Write Blackholio C++ server module --------- Signed-off-by: Jason Larabie <jason@clockworklabs.io> Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com> Co-authored-by: Ryan <r.ekhoff@clockworklabs.io> Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
SDK Test Procedure C++ - Rust Client
Rust client for testing the sdk-test-procedure-cpp module.
Setup
-
Build the C++ module:
cd .. .\compile.bat -
Start SpacetimeDB (if not already running):
spacetime start -
Publish the module:
cd build spacetime publish --project-path .. lib.wasm --clear-database -
Generate Rust bindings:
cd ../client spacetime generate --lang rust --out-dir src/module_bindings --project-path . -
Run the client:
cargo run
Environment Variables
SPACETIMEDB_HOST- SpacetimeDB host URL (default:http://localhost:3000)SPACETIMEDB_DB_NAME- Database name (default:sdk-test-procedure-cpp)
Procedure Tests
The client will test the following procedures:
return_primitive(lhs, rhs)- Returns sum of two uint32 valuesreturn_struct(a, b)- Returns struct with fieldsreturn_constant()- Returns constant 42will_fail(value)- Returns error when value=0
Notes
This is a standalone Rust project, not part of the root workspace.