daml_grpc/
lib.rs

1//! Daml ledger GRPC [API](https://docs.daml.com/app-dev/grpc/index.html).
2//!
3//! This library provides a client for the Daml ledger GRPC API.
4//!
5//! # Example
6//!
7//! The following example demonstrates creating a [`DamlGrpcClient`] using the [`DamlGrpcClientBuilder`], then creating
8//! a [`DamlSimpleExecutor`] using the [`DamlSimpleExecutorBuilder`] and finally creating and submitting a
9//! [`DamlCreateCommand`](data::command::DamlCreateCommand) to the ledger:
10//!
11//! ```no_run
12//! # use futures::future::Future;
13//! # use daml_grpc::data::command::DamlCommand;
14//! # use daml_grpc::DamlGrpcClientBuilder;
15//! # use daml_grpc::DamlSimpleExecutorBuilder;
16//! # use daml_grpc::data::DamlResult;
17//! # use daml_grpc::CommandExecutor;
18//! # use daml_grpc::data::command::DamlCreateCommand;
19//! # use daml_grpc::data::DamlIdentifier;
20//! # use daml_grpc::data::value::DamlRecord;
21//! # use std::error::Error;
22//! # fn main() -> DamlResult<()> {
23//! # futures::executor::block_on(async {
24//! let client = DamlGrpcClientBuilder::uri("http://localhost:8082").connect().await?;
25//! let executor = DamlSimpleExecutorBuilder::new(&client).act_as("Alice").build()?;
26//! let template_id = DamlIdentifier::new("...", "Fuji.PingPong", "Ping");
27//! let record = DamlRecord::new(vec![], None::<DamlIdentifier>);
28//! let command = DamlCreateCommand::new(template_id, record);
29//! let create_event = executor.execute_create(command).await?;
30//! # Ok(())
31//! # })
32//! # }
33//! ```
34//!
35//! Note that Daml commands such as [`DamlCreateCommand`](data::command::DamlCreateCommand) can be automatically
36//! generated for existing Daml templates using the various functions and macros provided in the [`daml-codegen`](https://docs.rs/daml-codegen/0.2.2) crate.
37//!
38//! Note also that the [`daml_value`](https://docs.rs/daml-macro/0.2.2/daml_macro/macro.daml_value.html) macro is
39//! provided to simplify the construction of [`DamlRecord`](data::value::DamlRecord) and
40//! [`DamlValue`](data::value::DamlValue) types.
41
42#![warn(clippy::all, clippy::pedantic, clippy::nursery, rust_2018_idioms)]
43#![allow(
44    clippy::module_name_repetitions,
45    clippy::use_self,
46    clippy::must_use_candidate,
47    clippy::missing_errors_doc,
48    clippy::missing_const_for_fn,
49    clippy::used_underscore_binding,
50    clippy::future_not_send,
51    clippy::return_self_not_must_use
52)]
53#![forbid(unsafe_code)]
54#![doc(html_favicon_url = "https://docs.daml.com/_static/images/favicon/favicon-32x32.png")]
55#![doc(html_logo_url = "https://docs.daml.com/_static/images/DAML_Logo_Blue.svg")]
56#![doc(html_root_url = "https://docs.rs/daml-grpc/0.2.2")]
57
58/// Daml API domain objects (i.e. values, commands, events).
59pub mod data;
60
61/// Daml GRPC API services (i.e. command & transaction services).
62pub mod service;
63
64/// Daml primitive data types.
65pub mod primitive_types;
66
67/// Serialize & Deserialize Daml types.
68pub mod serialize;
69
70/// Nat types for specifying Daml Numeric types.
71pub mod nat;
72
73mod ledger_client;
74pub use ledger_client::{DamlGrpcClient, DamlGrpcClientBuilder};
75
76mod command_factory;
77pub use command_factory::DamlCommandFactory;
78
79mod executor;
80pub use executor::{CommandExecutor, DamlSimpleExecutor, DamlSimpleExecutorBuilder, Executor};
81
82mod grpc_protobuf;
83mod util;