> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polynode.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Rust Settlement Stream

> Consume acknowledged Rust settlement subscriptions with reconnect replay, deduplication, and bounded backpressure.

```rust theme={null}
use polynode::{PolyNodeClient, PolyNodeEvent, WsMessage};
use polynode::ws::{StreamOptions, Subscription, SubscriptionType};

#[tokio::main]
async fn main() -> polynode::Result<()> {
    let client = PolyNodeClient::new(
        std::env::var("POLYNODE_API_KEY").expect("Set POLYNODE_API_KEY")
    )?;
    let mut stream = client.stream(StreamOptions::default()).await?;

    let ack = stream.subscribe_with_ack(
        Subscription::new(SubscriptionType::Settlements)
            .status("all")
            .min_size(100.0),
    ).await?;
    println!("{} {:?}", ack.subscription_id, ack.warnings);

    while let Some(message) = stream.next().await {
        match message? {
            WsMessage::Event(PolyNodeEvent::Settlement(event)) => {
                println!("pending {} {}", event.tx_hash, event.taker_size);
            }
            WsMessage::Event(PolyNodeEvent::StatusUpdate(event)) => {
                println!("confirmed {} {}", event.tx_hash, event.block_number);
            }
            WsMessage::Replay(notice) => {
                eprintln!("reconnect replay, guaranteed={}", notice.guaranteed);
            }
            WsMessage::UnknownEvent(event) => {
                println!("new event type {}: {}", event.wire_event_type, event.raw);
            }
            _ => {}
        }
    }

    stream.close().await?;
    Ok(())
}
```

Current presets are `Settlements`, `Trades`, `Prices`, `Dome`, `Fills`, `Combos`, `Redemptions`, `Redemption`, `Deposits`, `Blocks`, `Wallets`, `Markets`, `LargeTrades`, `Global`, `Oracle`, and `Chainlink`.

Subscription filters cover wallets, tokens, market IDs, slugs, condition IDs, side, direction, status, size bounds, event types, snapshots, reconnect `since`, Chainlink feeds and TWAP windows, combo and leg IDs, event IDs, module IDs, and action.

On reconnect, the stream resubscribes from the latest accepted timestamp with a small overlap and deduplicates the overlap. Replay is best effort within retained server history, not an unlimited delivery guarantee. `ReplayNotice.guaranteed` is always false.

The receive channel is bounded and applies backpressure rather than silently evicting messages. Poll `next()` continuously and move slow work to a bounded worker pipeline.

Short-form rotation deliberately closes and replaces its dedicated socket at every market boundary. See [Rust short-form](/sdks/rust/short-form).

Read the [shared settlement guide](/sdks/websocket-streaming) for the complete delivery contract.
