Daml Codegen
A library and a tool for generating Rust types from daml code.
This crate provides:
- A code generator backend for the of custom attributes and procedural macros defined in
the
daml-derivecrate - A
daml_codegenfunction which is designed to be used frombuild.rsfiles - A standalone codegen cli tool
Library
This crate should not be used directly when used as a library, instead you should depend on
the daml crate and enable the codegen feature:
[]
= { = "0.3.0", = [ "codegen" ] }
Install
cargo install daml-codegen
Usage
Daml GRPC Ledger API Code Generator
Usage: daml-codegen [OPTIONS] <dar>
Arguments:
<dar> Path to the input DAR file
Options:
-o, --output-dir <output> Output directory (default: '.')
-f, --module-filter <filter>... Regex(es) matched against fully-qualified module names
(e.g. 'MyPackage\.Foo\..*'). Only modules matching any
of the regexes are emitted; without --module-filter,
every module is emitted.
-i, --render-intermediate Render an intermediate representation instead of the
full Rust types (debugging aid)
-c, --combine-modules Emit one Rust file per DAR (default: one file per module)
-h, --help Print help
-V, --version Print version
Example
To generate Rust types from MyModel.dar combined into a single output file under
src/autogen/:
daml-codegen MyModel.dar --combine-modules -o src/autogen
License
daml-codegen is distributed under the terms of the Apache License (Version 2.0).
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in time by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
See LICENSE for details.
Copyright 2022-2026