Expand description
Daml-LF archive reader and decoder.
The codegen front-end of the Canton Rust SDK: it reads a .dar and decodes
its Daml-LF packages into the AST that canton-codegen lowers to IR and
turns into Rust. Most users never call this crate directly — they run
canton-codegen-cli (dpm codegen-rust).
Dar— the DAR container layer (zip +MANIFEST.MF→ the raw Daml-LF bytes of the main package and its dependencies).decode_all/decode_main_package— Daml-LF protobuf decode (LF 2.x → typed AST) with the interned-table resolvers.
The decode is built on the official daml-lf-archive schema: the
vendored daml_lf.proto / daml_lf2.proto under proto/ are Digital
Asset’s own archive definitions (pinned to a Daml 3.3 snapshot), so the
bytes→AST step is machine-generated from the authoritative source rather
than hand-written. The interpretation on top (version dispatch, interning,
reference resolution) is held to the official JVM daml-lf-archive
reader by a conformance oracle: tests/oracle.rs renders the decoded
type-signature surface and asserts byte-for-byte agreement with
tools/lf-oracle/LfOracle.scala, which reads the same DAR through
com.daml:daml-lf-archive-reader (the decoder Canton itself uses). No JVM
is required to use the SDK or the codegen — the oracle is dev/CI-only.
Structs§
- Dar
- A parsed DAR: its manifest fields plus the raw bytes of each
.dalf.
Enums§
- DarError
- An error opening or reading a DAR.
- Decode
Error - An error decoding Daml-LF package bytes.
Functions§
- decode_
all - Decode every package in a DAR, each paired with its package id (archive hash) — the PackageMap for resolving cross-package references.
- decode_
main_ package - Decode the DAR’s main package into the Daml-LF 2 AST, together with its
package id (the
Archivehash — the input to SCU/PackageMap and to qualifying cross-package references). - decode_
package - Decode a single package’s
.dalfbytes (anArchive) into the LF 2 AST and its package id (the archive hash). - decode_
payload - Decode an
ArchivePayload— the inner half of an archive, without the hash beside it. - imported_
package_ id - Resolve a
package_import_id— an index into the package’s explicit import table (package_imports.imported_packages) — to the target package’s id hash. Newer LF (2.dev / SDK 3.5+) references imported packages this way instead of by an interned id string. - interned_
dotted_ name - Resolve an interned dotted name (a module or type name) to its
.-joined form, e.g."Licensing.AppInstall". - interned_
str - Resolve an interned string by its
i32index into a package’sinterned_stringstable. - interned_
type - Resolve an interned type by its
i32index into a package’sinterned_typestable (LF 2.x stores types once and references them by index). - package_
name - The package name from its metadata (
PackageMetadata.name_interned_str). - package_
version - The package version from its metadata (
PackageMetadata.version_interned_str).