Temporal Rust Client
This crate provides a Rust client for interacting with the Temporal service. It can be used
standalone to start and manage workflows, or together with the
temporalio-sdk crate to run workers.
⚠️ This crate is under active development and should be considered prerelease. The API can and will continue to evolve.
Quick Start
Connecting and Starting Workflows with Environment Configuration
The simplest way to connect is to load connection settings from environment variables and/or a
temporal.toml config file:
use ;
async
This reads TEMPORAL_ADDRESS, TEMPORAL_NAMESPACE, TEMPORAL_API_KEY, TLS settings, and more
from the environment. See the envconfig module docs for the full list of
supported variables and the TOML file format.
Connecting and Starting Workflows with Explicit Options
use ;
use ;
use FromStr;
async
Signals, Queries, and Updates
Once you have a workflow handle, you can interact with the running workflow:
use ;
use ;
// Get a handle to an existing workflow (or use one from start_workflow)
let handle = client.;
// --- Signals (fire-and-forget messages) ---
handle.signal.await?;
// --- Queries (read workflow state) ---
let values = handle
.query
.await?;
// --- Updates (modify state and get a result) ---
let values = handle
.execute_update
.await?;
// Start an update and wait for acceptance only
let update_handle = handle
.start_update
.await?;
update_handle.get_result.await?;
// --- Untyped interactions (when types aren't known at compile time) ---
let pc = serde_json;
handle
.signal
.await?;
// UntypedQuery and UntypedUpdate work similarly
Cancelling and Terminating Workflows
use ;
// Request cancellation (workflow can handle this gracefully)
handle.cancel.await?;
// Terminate immediately (workflow cannot intercept this)
handle.terminate.await?;
Listing Workflows
use ListWorkflowsOptions;
use StreamExt;
let mut stream = client.list_workflows;
while let Some = stream.next.await
Raw gRPC Access
For operations not covered by the high-level API, access the underlying gRPC service clients directly:
let mut workflowf_service = client.connection.workflow_service;
let mut operator_service = client.connection.operator_service;