Skip to main content

write_rust_code

Function write_rust_code 

Source
pub fn write_rust_code(
    output_path: &str,
    models: &HashMap<String, String>,
    enums_code: Option<String>,
    composite_types_code: Option<String>,
    standalone: bool,
) -> Result<()>
Expand description

Write generated code to files in the output directory.

Creates:

  • {output}/src/lib.rs — module declarations and re-exports
  • {output}/src/{model_snake}.rs — model code for each model
  • {output}/src/enums.rs — all enum types (if any)
  • {output}/Cargo.tomlonly when standalone == true

When standalone is false (the default) the output is a plain directory of .rs source files ready to be included in an existing Cargo workspace without any generated Cargo.toml.