Skip to main content

temporalio_common/
workflow_definition.rs

1use crate::data_converters::{TemporalDeserializable, TemporalSerializable};
2
3/// Implement on a marker struct to define a workflow.
4///
5/// Typically, you will want to use the `#[workflow]` and `#[workflow_methods]` macros to define
6/// workflows. However, this trait may be implemented manually if desired.
7pub trait WorkflowDefinition {
8    /// Type of the input argument to the workflow
9    type Input: TemporalDeserializable + TemporalSerializable + 'static;
10    /// Type of the output of the workflow
11    type Output: TemporalDeserializable + TemporalSerializable + 'static;
12    /// The workflow type name
13    fn name(&self) -> &str;
14}
15
16/// Implement on a marker struct to define a query.
17///
18/// Typically, you will want to use the `#[query]` attribute inside a `#[workflow_methods]` macro
19/// to define updates. However, this trait may be implemented manually if desired.
20pub trait QueryDefinition {
21    /// The workflow type this query belongs to
22    type Workflow: WorkflowDefinition;
23    /// Type of the input argument to the query.
24    type Input: TemporalDeserializable + TemporalSerializable + 'static;
25    /// Type of the output of the query.
26    type Output: TemporalDeserializable + TemporalSerializable + 'static;
27
28    /// The workflow type name.
29    fn name(&self) -> &str;
30}
31
32/// Implement on a marker struct to define a signal.
33///
34/// Typically, you will want to use the `#[signal]` attribute inside a `#[workflow_methods]` macro
35/// to define signals. However, this trait may be implemented manually if desired.
36pub trait SignalDefinition {
37    /// The workflow type this signal belongs to
38    type Workflow: WorkflowDefinition;
39    /// Type of the input argument to the signal.
40    type Input: TemporalDeserializable + TemporalSerializable + 'static;
41
42    /// The workflow type name.
43    fn name(&self) -> &str;
44}
45
46/// Implement on a marker struct to define an update.
47///
48/// Typically, you will want to use the `#[update]` attribute inside a `#[workflow_methods]` macro
49/// to define updates. However, this trait may be implemented manually if desired.
50pub trait UpdateDefinition {
51    /// The workflow type this update belongs to
52    type Workflow: WorkflowDefinition;
53    /// Type of the input argument to the update.
54    type Input: TemporalDeserializable + TemporalSerializable + 'static;
55    /// Type of the output of the update.
56    type Output: TemporalDeserializable + TemporalSerializable + 'static;
57
58    /// The workflow type name.
59    fn name(&self) -> &str;
60}