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.3.0) crate.
37//!
38//! Note also that the [`daml_value`](https://docs.rs/daml-macro/0.3.0/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 // Style-only pedantic / nursery lints intentionally allowed
53 // workspace-wide — none affect correctness.
54 clippy::large_enum_variant,
55 clippy::too_many_lines,
56 clippy::non_canonical_partial_ord_impl,
57 clippy::too_long_first_doc_paragraph,
58 clippy::option_if_let_else,
59 clippy::trivially_copy_pass_by_ref,
60 // Proto-generated code (tonic-build / prost-build) derives PartialEq without Eq.
61 clippy::derive_partial_eq_without_eq,
62)]
63#![forbid(unsafe_code)]
64#![doc(html_favicon_url = "https://docs.daml.com/_static/images/favicon/favicon-32x32.png")]
65#![doc(html_logo_url = "https://docs.daml.com/_static/images/DAML_Logo_Blue.svg")]
66#![doc(html_root_url = "https://docs.rs/daml-grpc/0.3.0")]
67
68/// Daml API domain objects (i.e. values, commands, events).
69pub mod data;
70
71/// Daml GRPC API services (i.e. command & transaction services).
72pub mod service;
73
74/// Daml primitive data types.
75pub mod primitive_types;
76
77/// Serialize & Deserialize Daml types.
78pub mod serialize;
79
80/// Nat types for specifying Daml Numeric types.
81pub mod nat;
82
83mod ledger_client;
84pub use ledger_client::{DamlGrpcClient, DamlGrpcClientBuilder};
85
86mod command_factory;
87pub use command_factory::DamlCommandFactory;
88
89mod executor;
90pub use executor::{CommandExecutor, DamlSimpleExecutor, DamlSimpleExecutorBuilder};
91
92/// Raw prost-generated Ledger API v2 protobuf bindings.
93///
94/// Exposed so downstream crates (e.g. `roadrunner-proto`) can re-use the
95/// `transaction.proto` / `value.proto` types without re-vendoring the
96/// protos. The DTO wrappers in [`data`] sit on top of these; most user
97/// code should reach for the DTOs rather than the raw prost types.
98pub mod grpc_protobuf;
99mod util;