5 releases
0.2.2 | Mar 8, 2022 |
---|---|
0.2.1 | Mar 7, 2022 |
0.2.0 | Mar 4, 2022 |
0.1.1 | Mar 3, 2022 |
0.1.0 | Mar 1, 2022 |
#2475 in Development tools
67 downloads per month
Used in 8 crates
(6 directly)
2.5MB
9K
SLoC
Contains (Zip file, 510KB) TestingTypes-1_9_0-sdk_1_18_1-lf_1_14.dar, (Zip file, 415KB) TestingTypes-1_0_0-sdk_0_13_36-lf_1_6.dar, (Zip file, 380KB) TestingTypes-1_0_0-sdk_0_13_37-lf_1_7.dar, (Zip file, 355KB) TestingTypes-1_0_0-sdk_0_13_55-lf_1_8.dar, (Zip file, 365KB) TestingTypes-1_0_0-sdk_1_0_0-lf_1_8.dar, (Zip file, 355KB) TestingTypes-1_0_0-sdk_1_0_1-lf_1_8.dar and 1 more.
Daml LF
This crate provides a library for working with Daml-LF
packages.
This crate should not be used directly, instead you should depend on the daml
crate and enable the lf
or lf-full
features:
[dependencies]
daml = { version = "0.2.2", features = [ "lf" ] }
License
daml-lf
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
lib.rs
:
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:
default
Includes allDaml-LF
types except Daml expressions.full
Includes allDaml-LF
types.
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
.
Dependencies
~3–5.5MB
~101K SLoC