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());
})§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§
- element
- Representation of Daml types.
Structs§
- Daml
LfArchive - A
Daml LFarchive (aka adalffile). - Daml
LfArchive Payload - A
Daml LFarchive payload (aka “package”). - DarFile
- A collection of
Daml LFarchives combined with a manifest file (aka adarfile). - DarManifest
- Represents a manifest file found inside
darfiles. - Language
Feature Version - Minimum Daml LF language version support for a feature.
- Package
Info - Information about a
DamlPackage.
Enums§
- Daml
LfError - Represents
Daml-LFerrors. - Daml
LfHash Function - The hash function used to compute
- Daml
LfPackage - The supported
Daml LFpackage formats. - DarEncryption
Type - The encryption type of the archives in a dar file.
- DarManifest
Format - The format of the archives in a dar file.
- DarManifest
Version - The version of a dar file manifest.
- Language
V1Minor Version - Daml Ledger Fragment language V1 minor version.
- Language
Version - Daml Ledger Fragment language version.
Constants§
- DEFAULT_
ARCHIVE_ NAME - The default name for an unnamed archive.
Type Aliases§
- Daml
LfResult - Represents
Daml-LFresults.