schema_salad icon indicating copy to clipboard operation
schema_salad copied to clipboard

[WIP] Rust language backend support

Open giuseppe998e opened this issue 8 months ago • 5 comments

This PR brings the Rust language support to schema-salad-tool, enabling Rust code generation alongside existing backends.

Currently the salad-core library (crate), which will handle document (de)serialization, is undergoing a major refactoring. The code will be located in the giuseppe998e/schema_salad repository branch.

Current Status

  • [x] Code generation from Schema Salad schemas to Rust is implemented.
  • [ ] Deserialization logic in Rust is not yet implemented.
  • [ ] Serialization logic in Rust is still missing.
  • [ ] Comprehensive tests need to be written and validated.


This PR is still a draft, and feedback is highly appreciated!

giuseppe998e avatar Mar 05 '25 16:03 giuseppe998e

Hello @giuseppe998e ; would you like to have a meeting to discuss how to get this code merged?

mr-c avatar May 30 '25 13:05 mr-c

It is nice to see the progress @giuseppe998e ; let me know if you need help with that mypyc error. Here is a hint: https://mypyc.readthedocs.io/en/latest/native_classes.html#inheritance

mr-c avatar Aug 13 '25 14:08 mr-c

Hi @mr-c, I was about to reply to your first comment. Sorry for the delay in responding, but at that time, for personal reasons, I was unable to work on the extension until now.


Anyway, yes, I'm solving the compatibility issues (or at least I'm trying to)... The compilation fails (I think) due to an error related to @dataclass and inheritance, which I'm trying to understand.

giuseppe998e avatar Aug 13 '25 15:08 giuseppe998e

The compilation fails (I think) due to an error related to @dataclass and inheritance, which I'm trying to understand.

I solved it by completely removing the @dataclass annotations from the code. What a shame, I don't know if it's the only possible choice, but it's certainly not the cleanest. I would have gladly avoided writing all those __init__ methods.

giuseppe998e avatar Aug 13 '25 16:08 giuseppe998e

Codecov Report

:x: Patch coverage is 29.30728% with 398 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 77.84%. Comparing base (01aa050) to head (7464c78).

Files with missing lines Patch % Lines
schema_salad/rust_codegen.py 29.39% 391 Missing and 3 partials :warning:
schema_salad/codegen.py 20.00% 4 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #917      +/-   ##
==========================================
- Coverage   83.36%   77.84%   -5.52%     
==========================================
  Files          22       23       +1     
  Lines        4952     5515     +563     
  Branches     1185     1278      +93     
==========================================
+ Hits         4128     4293     +165     
- Misses        547      942     +395     
- Partials      277      280       +3     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Aug 13 '25 17:08 codecov[bot]