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

# Stream

This page lists the Rust SDK names for [Streams](https://docs.superdurable.io/concepts/primitives/stream.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                                                                                             |
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| Define a Stream and its byte capacity    | **Stream::new**, with **stream_capacity_bytes**                                                                | [Capacity and trimming](https://docs.superdurable.io/reference/server/runtime-data.md#stream-capacity)   |
| Declare it in the Flow                   | **PersistenceSchema::stream**, returned from **Flow::persistence**                                             | [Flow definition](https://docs.superdurable.io/reference/rust/flow.md#flow-definition)                   |
| Write a message from a Step              | **Stream::write**                                                                                              | [Write semantics](https://docs.superdurable.io/reference/server/runtime-data.md#stream-write-semantics)  |
| Write text chunks in batches from a Step | **Stream::buffered_text** and **Stream::buffered_text_with_options**, with **BufferedTextStreamOptions**       | [Buffer text chunks](https://docs.superdurable.io/reference/server/runtime-data.md#stream-buffered-text) |
| Write a message from a Client            | **Client::write_stream**                                                                                       | [Write semantics](https://docs.superdurable.io/reference/server/runtime-data.md#stream-write-semantics)  |
| Read the next message                    | **Client::read_stream** or **Client::read_stream_with_timeout**, with the **resume_token** of the last message | [Resumable reads](https://docs.superdurable.io/reference/server/runtime-data.md#stream-resumable-reads)  |
| List retained messages, newest first     | **Client::list_stream_messages**                                                                               | [List messages](https://docs.superdurable.io/reference/server/runtime-data.md#stream-listing)            |

**Stream::write** works in **wait_for**, **execute**, and the Flow timeout
handler. An RPC handler cannot write a Stream; there, **Stream::write** returns
a **HandlerError**. **Stream::write** sends the message immediately.

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

## Example

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