Skip to content

Commit 711be97

Browse files
pyranotaclaude[bot]rubenfiszel
authored
feat: add Rust client SDK documentation and changelog (#1014)
* feat: add Rust client SDK documentation and changelog - Add comprehensive Rust client documentation at docs/advanced/2_clients/rust_client.mdx - Create changelog entry for Rust client SDK release - Update navigation in sidebars.js to include Rust client - Add cross-references in Rust quickstart guide 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Ruben Fiszel <[email protected]> * polish docs Signed-off-by: pyranota <[email protected]> --------- Signed-off-by: pyranota <[email protected]> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Ruben Fiszel <[email protected]>
1 parent f5a65e1 commit 711be97

File tree

4 files changed

+199
-0
lines changed

4 files changed

+199
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
slug: rust-client-sdk
3+
version: v1.500.0
4+
title: Rust client SDK
5+
tags: ['Rust', 'SDK', 'Client', 'API']
6+
description: Windmill now provides a comprehensive Rust client SDK for interacting with the Windmill API. The `wmill` crate enables developers to build Rust applications that can manage resources, execute scripts, monitor job status, and integrate seamlessly with Windmill workflows.
7+
features:
8+
- Complete Rust client SDK with async/await support
9+
- Resource management and variable access
10+
- Script execution (sync and async)
11+
- Job status monitoring and result retrieval
12+
- Type-safe error handling with Rust enums
13+
- Integration with Windmill authentication
14+
- Customizable HTTP client configuration
15+
docs: /docs/advanced/clients/rust_client
16+
---
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Rust client
2+
3+
The Rust client library for Windmill provides a convenient way to interact with the Windmill platform's API from within your Rust applications. By authenticating with the `WM_TOKEN` reserved variable or custom tokens, you can utilize the Rust client to access various functionalities offered by Windmill.
4+
5+
<div className="inline-flex gap-2">
6+
<a href="https://crates.io/crates/wmill"><img src="https://img.shields.io/crates/v/wmill" alt="crates.io" /></a>
7+
<a href="https://docs.rs/wmill"><img src="https://img.shields.io/docsrs/wmill" alt="docs.rs" /></a>
8+
</div>
9+
10+
## Installation
11+
12+
To use the Rust client library, you need to add the `wmill` crate to your `Cargo.toml` dependencies:
13+
14+
```toml
15+
[dependencies]
16+
wmill = "^1.0"
17+
```
18+
19+
Or using cargo:
20+
21+
```bash
22+
cargo add wmill
23+
```
24+
25+
## Usage
26+
27+
28+
## Usage
29+
30+
### Initialize Client
31+
32+
```rust
33+
use wmill::Windmill;
34+
35+
#[tokio::main]
36+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
37+
// Read config from env vars
38+
let wm = Windmill::default()?;
39+
40+
// Or override specific values
41+
let wm = Windmill::new(
42+
Some("custom_token".to_string()),
43+
Some("my_workspace".to_string()),
44+
Some("http://localhost:8000".to_string())
45+
)?;
46+
47+
Ok(())
48+
}
49+
```
50+
51+
### Variables
52+
53+
```rust
54+
// Get variable (auto-parsed)
55+
let db_config: serde_json::Value = wm.get_variable("u/admin/db_config").await?;
56+
57+
// Get raw variable
58+
let raw_text = wm.get_variable_raw("u/user/text_note").await?;
59+
60+
// Set variable
61+
wm.set_variable("new_value".to_string(), "u/user/my_var", false).await?;
62+
```
63+
64+
### Resources
65+
66+
```rust
67+
// Get resource (typed)
68+
#[derive(serde::Deserialize)]
69+
struct DbConfig { host: String, port: u16 }
70+
71+
let config: DbConfig = wm.get_resource("u/admin/db").await?;
72+
73+
// Get raw resource
74+
let raw_json = wm.get_resource_any("u/admin/db").await?;
75+
76+
// Set resource
77+
wm.set_resource(
78+
Some(serde_json::json!({"host": "localhost", "port": 5432})),
79+
"u/admin/db",
80+
"postgresql"
81+
).await?;
82+
```
83+
84+
### Scripts
85+
86+
```rust
87+
// Run script async
88+
let job_id = wm.run_script_async(
89+
"u/user/my_script",
90+
false,
91+
serde_json::json!({"param": "value"}),
92+
Some(10) // Schedule in 10 seconds
93+
).await?;
94+
95+
// Run script sync
96+
let result = wm.run_script_sync(
97+
"u/user/my_script",
98+
false,
99+
serde_json::json!({"param": "value"}),
100+
Some(10),
101+
Some(30), // 30s timeout
102+
true, // Verbose
103+
true // Assert result not None
104+
).await?;
105+
```
106+
107+
### Jobs
108+
109+
```rust
110+
// Wait for job completion
111+
let result = wm.wait_job(&job_id, Some(60), true, true).await?;
112+
113+
// Get job status
114+
let status = wm.get_job_status(&job_id).await?; // Running/Waiting/Completed
115+
116+
// Get result directly
117+
let result = wm.get_result(&job_id).await?;
118+
```
119+
120+
### State Management
121+
122+
```rust
123+
// Get typed state
124+
#[derive(serde::Deserialize)]
125+
struct ScriptState { counter: i32 }
126+
127+
let state: ScriptState = wm.get_state().await?;
128+
129+
// Get raw state
130+
let raw_state = wm.get_state_any().await?;
131+
132+
// Update state
133+
wm.set_state(Some(serde_json::json!({"counter": 42}))).await?;
134+
```
135+
136+
### Progress Tracking
137+
138+
```rust
139+
// Set job progress
140+
wm.set_progress(75, None).await?; // Uses current job ID from env
141+
142+
// Get job progress
143+
let progress = wm.get_progress(Some(job_id.to_string())).await?;
144+
```
145+
146+
### Custom API Calls
147+
148+
The SDK provides direct access to underlying API endpoints through the ```call_api``` method, which works in both async and sync contexts:
149+
150+
```rust
151+
// Async usage
152+
#[tokio::main]
153+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
154+
let wm = Windmill::default()?;
155+
156+
// Make direct API call to get user
157+
let user = wm.call_api(wmill::apis::admin_api::get_user(
158+
&wm.client_config,
159+
&wm.workspace,
160+
"Alice"
161+
)).await;
162+
163+
println!("User details: {:?}", user);
164+
Ok(())
165+
}
166+
167+
// Sync usage
168+
fn main() {
169+
let wm = Windmill::default().unwrap();
170+
171+
// Make direct API call to get user
172+
let user = wm.call_api(wmill::apis::admin_api::get_user(
173+
&wm.client_config,
174+
&wm.workspace,
175+
"Bob"
176+
));
177+
178+
println!("User details: {:?}", user);
179+
}
180+
```

docs/getting_started/0_scripts_quickstart/9_rust_quickstart/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ boilerplate. Let's take a look:
108108
//! [dependencies]
109109
//! anyhow = "1.0.86"
110110
//! rand = "0.7.2"
111+
//! # wmill = "^1.0" # Windmill client SDK for API interactions
111112
//! ```
112113
//!
113114
//! Note that serde is used by default with the `derive` feature.
@@ -243,6 +244,7 @@ This script is a minimal working example, but there's a few more steps that can
243244
- Pass [variables and secrets](../../../core_concepts/2_variables_and_secrets/index.mdx)
244245
to a script.
245246
- Connect to [resources](../../../core_concepts/3_resources_and_types/index.mdx).
247+
- Use the [Rust client SDK](../../../advanced/2_clients/rust_client.mdx) to interact with Windmill's API from your applications.
246248
- [Trigger that script](../../8_triggers/index.mdx) in many ways.
247249
- Compose scripts in [Flows](../../../flows/1_flow_editor.mdx) or [Apps](../../../apps/0_app_editor/index.mdx).
248250
- You can [share your scripts](../../../misc/1_share_on_hub/index.md) with the community on [Windmill Hub](https://hub.windmill.dev). Once

sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,7 @@ const sidebars = {
992992
'advanced/sharing_common_logic/index',
993993
'advanced/clients/ts_client',
994994
'advanced/clients/python_client',
995+
'advanced/clients/rust_client',
995996
'advanced/explicit_progress/index',
996997
'misc/share_on_hub/index'
997998
]

0 commit comments

Comments
 (0)