feat(bindings-cpp-ffi): add Rust FFI crate for WASM modules#4773
Open
euxaristia wants to merge 1 commit intoclockworklabs:masterfrom
Open
feat(bindings-cpp-ffi): add Rust FFI crate for WASM modules#4773euxaristia wants to merge 1 commit intoclockworklabs:masterfrom
euxaristia wants to merge 1 commit intoclockworklabs:masterfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bb1e667316
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
bb1e667 to
22e9c5d
Compare
Rewrite the core C++ type registration and FFI dispatch layer from crates/bindings-cpp in Rust. The new crate provides: - ModuleTypeRegistration: full SATS type registration with circular reference detection, error module generation, and BSATN serialization - FFI dispatch: __describe_module__, __call_reducer__, __call_view__, __call_view_anon__, __call_procedure__ with proper Identity/ConnectionId reconstruction and BytesSource/BytesSink I/O - Preinit functions: __preinit__01_clear_global_state and __preinit__99_validate_types matching the C++ originals Replaces ~1,414 lines of C++ with ~1,139 lines of Rust (19% reduction) plus 96 unit tests (100% coverage). Clippy-clean and fmt-clean.
22e9c5d to
c07421e
Compare
Author
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
crates/bindings-cpp-ffi, a new Rust crate providing type registration and FFI dispatch for SpacetimeDB WASM modules. This is a Rust implementation of the logic found incrates/bindings-cpp, providing a production-ready, 100%-tested alternative to the existing C++ bindings.What's included
Type Registration (
module_type_registration.rs)__preinit__99_validate_typesbehaviorRawModuleDefV10FFI Dispatch (
ffi.rs)__describe_module__— serializes module definition to host__call_reducer__— validates ID, reads BSATN args, dispatches to registered handler, writes errors to sink__call_view__/__call_view_anon__— reconstructs sender identity, reads args, dispatches, prependsViewResultHeader__call_procedure__— full dispatch with sender/connection reconstruction__preinit__01_clear_global_state/__preinit__99_validate_types— WASM preinit exportsbytes_sink_write/bytes_source_read/bytes_source_remaining_length— proper FFI I/O with partial read handlingPublic API
register_reducer,register_view,register_view_anon,register_procedure— handler registration returning dispatch indicesregister_type— type registration with the typespacehas_registration_error/registration_error— error introspectionSize comparison
Verification
Notes
memberslist and builds cleanly alongside the existing C++ bindings.