Skip to content

[WIP] Rust language backend support #917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

giuseppe998e
Copy link

@giuseppe998e giuseppe998e commented Mar 5, 2025

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

  • 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 and others added 5 commits March 5, 2025 16:17
This commit includes the Python module responsible for generating code
based on a given schema.

The `schema_salad/rust/salad-core` folder serves as a placeholder for
Rust code logic that will enable document (de)serialization, which is
still a work in progress due to ongoing code refactoring.
The code for this refactoring can be found in the
"giuseppe998e/schema_salad" repository branch.
@mr-c
Copy link
Member

mr-c commented May 30, 2025

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

@giuseppe998e giuseppe998e force-pushed the main branch 4 times, most recently from c130c8d to 31d3fbe Compare August 13, 2025 12:49
@mr-c
Copy link
Member

mr-c commented Aug 13, 2025

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

This reverts commit 62162d2.
Thats was not the problem.

---

Current issue:
```
  tests/test_cli_args.py:8: in <module>
      import schema_salad.main as cli_parser
  schema_salad/main.py:16: in <module>
      ???
  schema_salad/codegen.py:18: in <module>
      ???
  schema_salad/rust_codegen.py:266: in <module>
      ???
  E   AttributeError: attribute '__dict__' of 'type' objects is not
writable
```
@giuseppe998e
Copy link
Author

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
Copy link
Author

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.

Copy link

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 29.30728% with 398 lines in your changes missing coverage. Please review.
✅ 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 ⚠️
schema_salad/codegen.py 20.00% 4 Missing ⚠️
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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants