---
title: "SubFlow"
description: "This page lists the Rust SDK names for SubFlows."
canonical_url: "https://docs.superdurable.io/reference/rust/subflow/"
source: "docs/reference/rust/subflow.mdx"
locale: "en"
---

# SubFlow

This page lists the Rust SDK names for [SubFlows](https://docs.superdurable.io/concepts/primitives/subflow.md).
The doc comment of each API gives its parameters, defaults, and errors. Read
them in the [Rust SDK API reference](https://docs.superdurable.io/reference/rust.md#api-reference).

<a id="api-names"></a>

## API names

| Task                                                 | Rust API                                                                                                       | Dex behavior                                                                                             |
| ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| Start a child Flow and wait for it                   | **SubFlow::run** in **wait_for**                                                                               | [SubFlows](https://docs.superdurable.io/reference/server/runtime-data.md#subflows)                       |
| Set the child timeout, Attributes, and configuration | **SubFlowOptions**, with **SubFlow::run_with_options**                                                         | [SubFlowOptions](https://docs.superdurable.io/reference/server/runtime-data.md#subflow-options)          |
| Choose what happens to an existing child             | **reuse_policy** of **SubFlowOptions**, with **SubFlowReusePolicy**                                            | [SubFlowReusePolicy](https://docs.superdurable.io/reference/server/runtime-data.md#subflow-reuse-policy) |
| Read the child result                                | **SubFlow::condition_result** or **SubFlow::condition_result_at** in **execute**. It returns a **FlowResult**. | [SubFlow results](https://docs.superdurable.io/reference/rust/waits.md#subflow-results)                  |
| Read the generated child Flow ID                     | **SubFlow::flow_id** or **SubFlow::flow_id_at**                                                                | [SubFlowReusePolicy](https://docs.superdurable.io/reference/server/runtime-data.md#subflow-reuse-policy) |
| Stop a child that lost an **AnyOf**                  | **Client::stop_flow** with the child Flow ID                                                                   | [Stop a Flow](https://docs.superdurable.io/reference/server/runtime-client.md#stop-a-flow)               |

<a id="step-type-rule"></a>

## Step types that start SubFlows

Changed in 1.45: a Step whose Step type contains a dash (-) cannot start
SubFlows.

Dex builds each child Flow ID from the parent Flow ID, the Step execution ID,
and the SubFlow index. It joins them with a dash. The Step execution ID starts
with the Step type. A dash in the Step type therefore lets two parents generate
the same child Flow ID.

If such a Step returns a **Wait** with a **SubFlow** Condition from
**wait_for**, the Worker logs a warning and sends the result unchanged. The
server rejects it as an invalid Worker response. It fails the attempt without
retry, so under the default policy the Flow fails. Steps with a dash in their
Step type can still use every other Condition.

To start SubFlows from the Step, rename its Step type. Override
**Step::step_type** to return a name without a dash. The default Step type is
the Rust type name, which never contains a dash.

<a id="example"></a>

## Example

Example: [examples/rust/src/primitives/subflow/flow.rs](https://github.com/superdurable/dex/tree/main/examples/rust/src/primitives/subflow/flow.rs)
