en un clic
port-c-module
// Guide for porting a C module to Rust. Use this when starting to port a C module to Rust.
// Guide for porting a C module to Rust. Use this when starting to port a C module to Rust.
Compile the project to verify changes build successfully. Use this to verify your changes build properly together with the complete project and dependencies, and make sure to use it before running end to end tests.
Investigate a RediSearch flaky-test report from a Jira key, CI failure, test id, or local logs. Use this to collect evidence, identify a supported root cause, and propose a real fix; if the evidence is insufficient, say so and ask for the missing data instead of suggesting workaround-only fixes or skip_until.
Fix merge conflicts in a jj change and its ancestors, starting from the oldest conflict. Use this when a jj change or its ancestors have conflicts that need resolving.
Check code quality and formatting before committing changes. Use this to verify your changes meet our coding standards.
Run Rust benchmarks and compare performance with the C implementation. Use this when you work on migrating C code to Rust and want to ensure performance is not regressed.
Run Rust tests after making changes to verify correctness. Use this when you want to verify your changes to Rust code.
| name | port-c-module |
| description | Guide for porting a C module to Rust. Use this when starting to port a C module to Rust. |
| disable-model-invocation | true |
Guide for porting a C module to Rust.
The module name to port should be provided as an argument (e.g., /port-module triemap).
Module to port: $ARGUMENTS
Use this skill when starting to port a C module to Rust.
First, understand the C module you're porting (look for $ARGUMENTS.c and $ARGUMENTS.h in src/):
.c and .h files in src/tests/ are relevant to this moduleCreate a $ARGUMENTS_plan.md file to outline the steps and decisions for porting the module.
Determine if the C code should be modified, at this stage, to ease the porting process.
For example:
cargo new src/redisearch_rs/$ARGUMENTS --lib
criterionproptest for property-based testing where appropriateCreate an FFI crate to expose the new Rust module to the C codebase:
cargo new src/redisearch_rs/c_entrypoint/${ARGUMENTS}_ffi --lib
FFI crate should:
#[unsafe(no_mangle)] pub extern "C" fn functions// SAFETY: commentsC header files for Rust FFI crates are auto-generated. No need to use their full path in imports,
use just their name (e.g. #include $ARGUMENTS.h; for ${ARGUMENTS}_ffi)
./build.sh RUN_UNIT_TESTS # C/C++ unit tests
./build.sh RUN_PYTEST # Integration tests
See src/redisearch_rs/trie_rs/ for a high-quality example:
c_entrypoint/trie_ffi/