Skip to content

Commit d3b701b

Browse files
committed
feat(rust): add rust codegen module
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.
1 parent 964fa75 commit d3b701b

File tree

7 files changed

+1156
-0
lines changed

7 files changed

+1156
-0
lines changed

schema_salad/codegen.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from .java_codegen import JavaCodeGen
1616
from .python_codegen import PythonCodeGen
1717
from .ref_resolver import Loader
18+
from .rust_codegen import RustCodeGen
1819
from .schema import shortname
1920
from .typescript_codegen import TypeScriptCodeGen
2021
from .utils import aslist
@@ -99,6 +100,10 @@ def codegen(
99100
gen = TypeScriptCodeGen(base, target=target, package=pkg, examples=examples)
100101
elif lang == "dotnet":
101102
gen = DotNetCodeGen(base, target=target, package=pkg, examples=examples)
103+
elif lang == "rust":
104+
gen = RustCodeGen(base_uri=base, package=pkg, salad_version=salad_version, target=target)
105+
gen.parse(j)
106+
return
102107
else:
103108
raise SchemaSaladException(f"Unsupported code generation language {lang!r}")
104109

schema_salad/rust/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target/
2+
Cargo.lock

schema_salad/rust/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "{package_name}"
3+
version = "{package_version}"
4+
publish = false
5+
edition = "2021"
6+
7+
[features]
8+
# TBD ...
9+
10+
[dependencies]
11+
# This is supposed to be imported from `crates.io`
12+
salad-core = { path = "salad-core" }
13+

schema_salad/rust/salad-core/.gitkeep

Whitespace-only changes.

schema_salad/rust/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Generated code
2+

0 commit comments

Comments
 (0)