From ef1347431719682fd38b2b91c877562d8fbbb1b0 Mon Sep 17 00:00:00 2001 From: Marc Duiker Date: Fri, 21 Nov 2025 14:53:12 +0000 Subject: [PATCH 1/2] Remove rust submodule Signed-off-by: Marc Duiker --- .gitmodules | 3 --- sdkdocs/rust | 1 - 2 files changed, 4 deletions(-) delete mode 160000 sdkdocs/rust diff --git a/.gitmodules b/.gitmodules index cb2249af216..4d8f013fb01 100644 --- a/.gitmodules +++ b/.gitmodules @@ -20,6 +20,3 @@ [submodule "sdkdocs/pluggable-components/go"] path = sdkdocs/pluggable-components/go url = https://github.com/dapr-sandbox/components-go-sdk -[submodule "sdkdocs/rust"] - path = sdkdocs/rust - url = https://github.com/dapr/rust-sdk.git diff --git a/sdkdocs/rust b/sdkdocs/rust deleted file mode 160000 index 4475ed57cfd..00000000000 --- a/sdkdocs/rust +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4475ed57cfdcb912a828f43cace8c0bea3eb99e1 From e47e54b1bb995010c3a725c65a79b725487816c9 Mon Sep 17 00:00:00 2001 From: Marc Duiker Date: Fri, 21 Nov 2025 14:59:17 +0000 Subject: [PATCH 2/2] Move Rust SDK docs to main docs Signed-off-by: Marc Duiker --- hugo.yaml | 4 +- .../rust-contributing.md | 38 ++++++ .../rust/content/en/rust-sdk-docs/_index.md | 27 ++++ .../en/rust-sdk-docs/rust-client/_index.md | 127 ++++++++++++++++++ 4 files changed, 194 insertions(+), 2 deletions(-) create mode 100644 sdkdocs/rust/content/en/rust-sdk-contributing/rust-contributing.md create mode 100644 sdkdocs/rust/content/en/rust-sdk-docs/_index.md create mode 100644 sdkdocs/rust/content/en/rust-sdk-docs/rust-client/_index.md diff --git a/hugo.yaml b/hugo.yaml index 31b591c9817..bd4ecdd06f5 100644 --- a/hugo.yaml +++ b/hugo.yaml @@ -308,10 +308,10 @@ module: - source: sdkdocs/js/daprdocs/content/en/js-sdk-contributing target: content/contributing/sdk-contrib/ lang: en - - source: sdkdocs/rust/daprdocs/content/en/rust-sdk-docs + - source: sdkdocs/rust/content/en/rust-sdk-docs target: content/developing-applications/sdks/rust lang: en - - source: sdkdocs/rust/daprdocs/content/en/rust-sdk-contributing + - source: sdkdocs/rust/content/en/rust-sdk-contributing target: content/contributing/sdk-contrib/ lang: en - source: sdkdocs/pluggable-components/dotnet/content/en/dotnet-sdk-docs diff --git a/sdkdocs/rust/content/en/rust-sdk-contributing/rust-contributing.md b/sdkdocs/rust/content/en/rust-sdk-contributing/rust-contributing.md new file mode 100644 index 00000000000..e5db90166a2 --- /dev/null +++ b/sdkdocs/rust/content/en/rust-sdk-contributing/rust-contributing.md @@ -0,0 +1,38 @@ +--- +type: docs +title: "Contributing to the Rust SDK" +linkTitle: "Rust SDK" +weight: 3000 +description: Guidelines for contributing to the Dapr Rust SDK +--- + +When contributing to the [Rust SDK](https://github.com/dapr/rust-sdk) the following rules and best-practices should be followed. + +## Examples + +The `examples` directory contains code samples for users to run to try out specific functionality of the various Rust SDK packages and extensions. It also hosts component examples used for validation. When writing new and updated samples keep in mind: + +- All examples should be runnable on Windows, Linux, and MacOS. While Rust code is consistent among operating systems aside from minor OS-feature gating, any pre/post example commands should provide options through [tabpane]({{% ref "contributing-docs.md#tabbed-content" %}}) +- Contain steps to download/install any required pre-requisites. Someone coming in with a fresh OS install should be able to start on the example and complete it without an error. Links to external download pages are fine. +- Examples should be pass validation and include mechanical markdown steps and be added to the validation workflow [TBA](#) + +## Docs + +The `daprdocs` directory contains the markdown files that are rendered into the [Dapr Docs](https://docs.dapr.io) website. When the documentation website is built this repo is cloned and configured so that its contents are rendered with the docs content. When writing docs keep in mind: + + - All rules in the [docs guide]({{% ref contributing-docs.md %}}) should be followed in addition to these. + - All files and directories should be prefixed with `rust-` to ensure all file/directory names are globally unique across all Dapr documentation. + +## Update Protobufs + +To pull the protobufs from the `dapr/dapr` repo you can run the script in the repo root like so: + +```bash +./update-protos.sh +``` + +By default, the script fetches the latest proto updates from the master branch of the Dapr repository. If you need to choose a specific release or version, use the -v flag: + +```bash +./update-protos.sh -v v1.13.0 +``` diff --git a/sdkdocs/rust/content/en/rust-sdk-docs/_index.md b/sdkdocs/rust/content/en/rust-sdk-docs/_index.md new file mode 100644 index 00000000000..da2500261de --- /dev/null +++ b/sdkdocs/rust/content/en/rust-sdk-docs/_index.md @@ -0,0 +1,27 @@ +--- +type: docs +title: "Dapr Rust SDK" +linkTitle: "Rust" +weight: 1000 +description: Rust SDK packages for developing Dapr applications +no_list: true +cascade: + github_repo: https://github.com/dapr/rust-sdk + github_subdir: daprdocs/content/en/rust-sdk-docs + path_base_for_github_subdir: content/en/developing-applications/sdks/rust/ + github_branch: main +--- + +{{% alert title="Note" color="primary" %}} +The Dapr Rust-SDK is currently in Alpha. Work is underway to bring it to a stable release and will likely involve breaking changes. +{{% /alert %}} + +A client library to help build Dapr applications using Rust. This client is targeting support for all public Dapr APIs while focusing on idiomatic Rust experiences and developer productivity. + +{{% cardpane %}} +{{% card title="**Client**" %}} + Use the Rust Client SDK for invoking public Dapr APIs + + [Learn more about the Rust Client SDK]({{% ref rust-client %}}) +{{% /card %}} +{{% /cardpane %}} diff --git a/sdkdocs/rust/content/en/rust-sdk-docs/rust-client/_index.md b/sdkdocs/rust/content/en/rust-sdk-docs/rust-client/_index.md new file mode 100644 index 00000000000..74c8ddb106f --- /dev/null +++ b/sdkdocs/rust/content/en/rust-sdk-docs/rust-client/_index.md @@ -0,0 +1,127 @@ +--- +type: docs +title: "Getting started with the Dapr client Rust SDK" +linkTitle: "Client" +weight: 20000 +description: How to get up and running with the Dapr Rust SDK +no_list: true +--- + +The Dapr client package allows you to interact with other Dapr applications from +a Rust application. + +{{% alert title="Note" color="primary" %}} +The Dapr Rust-SDK is currently in Alpha. Work is underway to bring it to a +stable release and will likely involve breaking changes. +{{% /alert %}} + +## Prerequisites + +- [Dapr CLI]({{% ref install-dapr-cli.md %}}) installed +- Initialized [Dapr environment]({{% ref install-dapr-selfhost.md %}}) +- [Rust installed](https://www.rust-lang.org/tools/install) + +## Import the client package + +Add Dapr to your `cargo.toml` + +```toml +[dependencies] +dapr = "0.16" +``` + +You can either reference `dapr::Client` or bind the full path to a new name as follows: + +```rust +use dapr::Client as DaprClient; +``` + +## Instantiating the Dapr client + +```rust +let addr = "https://127.0.0.1".to_string(); + +let mut client = dapr::Client::::connect(addr, +port).await?; +``` + +Alternatively if you would like to specify a custom port, this can be done by using this connect method: + +```rust +let mut client = dapr::Client::::connect_with_port(addr, "3500".to_string()).await?; +``` + +## Building blocks + +The Rust SDK allows you to interface with the +[Dapr building blocks]({{% ref building-blocks %}}). + +### Service Invocation (gRPC) + +To invoke a specific method on another service running with Dapr sidecar, the +Dapr client provides two options: + +Invoke a (gRPC) service + +```rust +let response = client + .invoke_service("service-to-invoke", "method-to-invoke", Some(data)) + .await + .unwrap(); +``` + +For a full guide on service invocation, visit +[How-To: Invoke a service]({{% ref howto-invoke-discover-services.md %}}). + +### State Management + +The Dapr Client provides access to these state management methods: `save_state` +, `get_state`, `delete_state` that can be used like so: + +```rust +let store_name = String::from("statestore"); + +let key = String::from("hello"); +let val = String::from("world").into_bytes(); + +// save key-value pair in the state store +client + .save_state(store_name, key, val, None, None, None) + .await?; + +let get_response = client + .get_state("statestore", "hello", None) + .await?; + +// delete a value from the state store +client + .delete_state("statestore", "hello", None) + .await?; +``` + +Multiple states can be sent with the `save_bulk_states` method. + +For a full guide on state management, visit +[How-To: Save & get state]({{% ref howto-get-save-state.md %}}). + +### Publish Messages + +To publish data onto a topic, the Dapr client provides a simple method: + +```rust +let pubsub_name = "pubsub-name".to_string(); +let pubsub_topic = "topic-name".to_string(); +let pubsub_content_type = "text/plain".to_string(); + +let data = "content".to_string().into_bytes(); +client + .publish_event(pubsub_name, pubsub_topic, pubsub_content_type, data, None) + .await?; +``` + +For a full guide on pub/sub, visit +[How-To: Publish & subscribe]({{% ref howto-publish-subscribe.md %}}). + +## Related links + +[Rust SDK Examples](https://github.com/dapr/rust-sdk/tree/master/examples)