1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//! Functionality related to defining and interacting with workflows
//!
//! This module contains traits and types for implementing workflows using the
//! `#[workflow]` and `#[workflow_methods]` macros.
//!
//! Example usage:
//! ```
//! use temporalio_macros::{workflow, workflow_methods};
//! use temporalio_workflow::{
//! SyncWorkflowContext, WorkflowContext, WorkflowContextView, WorkflowResult,
//! };
//!
//! #[workflow]
//! pub struct MyWorkflow {
//! counter: u32,
//! }
//!
//! #[workflow_methods]
//! impl MyWorkflow {
//! #[init]
//! pub fn new(ctx: &WorkflowContextView, input: String) -> Self {
//! Self { counter: 0 }
//! }
//!
//! // Async run method uses ctx.state() for reading
//! #[run]
//! pub async fn run(ctx: &mut WorkflowContext<Self>) -> WorkflowResult<String> {
//! let counter = ctx.state(|s| s.counter);
//! Ok(format!("Done with counter: {}", counter))
//! }
//!
//! // Sync signals use &mut self for direct mutations
//! #[signal]
//! pub fn increment(&mut self, ctx: &mut SyncWorkflowContext<Self>, amount: u32) {
//! self.counter += amount;
//! }
//!
//! // Queries use &self with read-only context
//! #[query]
//! pub fn get_counter(&self, ctx: &WorkflowContextView) -> u32 {
//! self.counter
//! }
//! }
//! ```
/// Deterministic `select!` for use in Temporal workflows.
///
/// Polls branches in declaration order (top to bottom), ensuring deterministic
/// behavior across workflow replays. Delegates to [`futures_util::select_biased!`].
///
/// All workflow futures (timers, activities, child workflows, etc.) implement
/// `FusedFuture`, so they can be stored in variables and passed to `select!`
/// without needing `.fuse()`.
///
/// # Example
///
/// ```ignore
/// use temporalio_sdk::workflows::select;
/// use temporalio_sdk::WorkflowContext;
/// use std::time::Duration;
///
/// # async fn hidden(ctx: &mut WorkflowContext<()>) {
/// select! {
/// _ = ctx.timer(Duration::from_secs(60)) => { /* timer fired */ }
/// reason = ctx.cancelled() => { /* cancelled */ }
/// };
/// # }
/// ```
pub use crate__temporal_select as select;
/// Deterministic `join!` for use in Temporal workflows.
///
/// Polls all futures concurrently to completion in declaration order,
/// ensuring deterministic behavior across workflow replays. Delegates
/// to [`futures_util::join!`].
///
/// # Example
///
/// ```ignore
/// use temporalio_sdk::workflows::join;
///
/// # async fn hidden() {
/// let future_a = async { 1 };
/// let future_b = async { 2 };
/// let (a, b) = join!(future_a, future_b);
/// # }
/// ```
pub use crate__temporal_join as join;
use crateSdkGuardedFuture;
use FutureExt;
pub use crate;
/// Deterministic `join_all` for use in Temporal workflows.
///
/// Polls a collection of futures concurrently to completion in declaration order,
/// returning a `Vec` of their results.
///
/// # Example
///
/// ```ignore
/// use temporalio_sdk::workflows::join_all;
/// use temporalio_sdk::WorkflowContext;
/// use std::time::Duration;
///
/// # async fn hidden(ctx: &mut WorkflowContext<()>) {
/// let timers = vec![
/// ctx.timer(Duration::from_secs(1)),
/// ctx.timer(Duration::from_secs(2)),
/// ];
/// let results = join_all(timers).await;
/// # }
/// ```
/// Future returned by [`join_all`].
;