Expand description
A library for working with Daml-LF.
Compiled Daml packages are represented as Daml-LF (
aka “Ledger Fragment”) archives. An archive is a protobuf serialized bytes array which is typically stored in a
dalf file. Multiple dalf archives can be combined along with a manifest file into a Dar (“Daml Archive”)
file.
Elements
The element module contains a higher level representation of all Daml-LF types and provide several convenience
methods to simplify working with Daml-LF types over the raw types generated from the protobuf definitions.
These types are typically constructed by converting an existing DarFile, DamlLfArchive or
DamlLfArchivePayload which can be loaded from a file or downloaded from a Daml ledger.
In the following example the example.dar is loaded from a file, converted to a DamlArchive and finally the id
of the main package is extracted:
let dar = DarFile::from_file("Example.dar")?;
let package_id = dar.apply(|archive| archive.main_package_id().to_owned())?;Interning
Interned data is automatically managed by the element items. During conversion all element items borrow
interned data from the underlying source and so no additional allocations are required per element.
However if an owned (i.e. bounded by 'static) version is required, such as to pass to a thread or an async
executors, the method DarFile::to_owned_archive is provided to perform this conversion and allocate separate
copies of all interned data per element as required.
The following example loads Example.dar from a file, converts it to an owned
DamlArchive that is suitable to be passed to a new thread:
let archive = DarFile::from_file("Example.dar")?.to_owned_archive()?;
thread::spawn(move || {
dbg!(archive.name());
})
.join()
.unwrap();Features
The following features are defined:
defaultIncludes allDaml-LFtypes except Daml expressions.fullIncludes allDaml-LFtypes.
Downloading Daml Packages
Serialized Daml-LF archives may also be retrieved from an existing ledger via the GetPackage method of the GRPC
package_service (see here).
The daml-grpc create provides an implementation of this service in the daml_package_service module.
The daml-util crate provides the DamlPackages helper to simplify downloading of packages form a Daml
ledger and converting to a DarFile or collections of DamlLfArchive or DamlLfArchivePayload.
Versions
This library supports all Daml-LF LanguageVersion from LanguageVersion::V1_0 up to
LanguageVersion::V1_14.
Modules
Representation of Daml types.
Structs
A Daml LF archive (aka a dalf file).
A Daml LF archive payload (aka “package”).
A collection of Daml LF archives combined with a manifest file (aka a dar file).
Represents a manifest file found inside dar files.
Minimum Daml LF language version support for a feature.
Information about a DamlPackage.
Enums
Represents Daml-LF errors.
The hash function used to compute
The supported Daml LF package formats.
The encryption type of the archives in a dar file.
The format of the archives in a dar file.
The version of a dar file manifest.
Daml Ledger Fragment language V1 minor version.
Daml Ledger Fragment language version.
Constants
The default name for an unnamed archive.
Type Definitions
Represents Daml-LF results.