Has anybody written any Rust application against the Ledger API?
App Development4 posts386 views3 likesLast activity Feb 2022
GY
gyorgybalazsiOP
Oct 2021I would be interested how you included the whole tree of .proto files.
This is my starting point and it only explains how single .proto files can be used:
hyperium/tonic/blob/debcafe08cd64f03bff2fee0eaa1521e47794a8a/examples/helloworld-tutorial.md
# Getting Started
This tutorial is meant to be an introduction to Tonic and assumes that you have basic [Rust] experience as well as an understanding of what [protocol buffers] are. If you don't, feel free to read up on the pages linked in this paragraph and come back to this tutorial once you feel you are ready!
[rust]: https://www.rust-lang.org/
[protocol buffers]: https://developers.google.com/protocol-buffers/docs/overview
## Prerequisites
To run the sample code and walk through the tutorial, the only prerequisite is Rust itself.
[rustup] is a convenient tool to install it, if you haven't already.
[rustup]: https://rustup.rs
## Project Setup
For this tutorial, we will start by creating a new Rust project with Cargo:
```shell
$ cargo new helloworld-tonic
This file has been truncated. show original
ST
stefanobaghino-da
Nov 2021Not sure of whether you can pass a directory and have it walk recursively (although that’s probably a nice contribution to make to the project, if they don’t) but it looks like you can use tonic_build::configure() to add more files (see the examples here).
GY
gyorgybalazsi
Nov 2021Thank you!
GY
gyorgybalazsi
Feb 2022Yes, this is the build.rs which does the job:
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.build_server(false)
.compile(
&[ // the list of protos
"com/daml/ledger/api/v1/admin/config_management_service.proto",
"com/daml/ledger/api/v1/admin/package_management_service.proto",
"com/daml/ledger/api/v1/admin/participant_pruning_service.proto",
"com/daml/ledger/api/v1/admin/party_management_service.proto",
"com/daml/ledger/api/v1/testing/reset_service.proto",
"com/daml/ledger/api/v1/testing/time_service.proto",
"com/daml/ledger/api/v1/active_contracts_service.proto",
"com/daml/ledger/api/v1/command_completion_service.proto",
"com/daml/ledger/api/v1/command_service.proto",
"com/daml/ledger/api/v1/command_submission_service.proto",
"com/daml/ledger/api/v1/commands.proto",
"com/daml/ledger/api/v1/completion.proto",
"com/daml/ledger/api/v1/event.proto",
"com/daml/ledger/api/v1/experimental_features.proto",
"com/daml/ledger/api/v1/ledger_configuration_service.proto",
"com/daml/ledger/api/v1/ledger_identity_service.proto",
"com/daml/ledger/api/v1/ledger_offset.proto",
"com/daml/ledger/api/v1/package_service.proto",
"com/daml/ledger/api/v1/transaction.proto",
"com/daml/ledger/api/v1/transaction_filter.proto",
"com/daml/ledger/api/v1/transaction_service.proto",
"com/daml/ledger/api/v1/value.proto",
"com/daml/ledger/api/v1/version_service.proto",
],
&["."], // specify the root location to search proto dependencies
)?;
Ok(())
}