---
source_url: https://www.pubnub.com/docs/sdks/rust/status-events
title: Status Events for Rust SDK
updated_at: 2026-06-04T11:13:05.572Z
sdk_name: PubNub Rust SDK
sdk_version: 0.7.0
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Status Events for Rust SDK

PubNub Rust SDK, use the latest version: 0.7.0

Install:

```bash
cargo add pubnub@0.7.0
```

The PubNub Rust Software Development Kit (SDK) reports status events that describe connection state and error conditions. This page explains each status and when it appears.

:::warning Subscribe loop
These status events apply to the latest subscription architecture in the Rust SDK introduced and enabled by default in version 0.3.0.
:::

The PubNub Rust SDK provides status events to notify you about the state of the SDK through the `ConnectionStatus` enum.

## Subscription-related statuses

The `ConnectionStatus` enum defines the following subscription-related values:

| Status | Description | Added in version |
| --- | --- | --- |
| `Connected` | The connection has been established and is ready to receive real-time updates. Triggered when handshake is successful and subscription begins. | 0.2.1 |
| `Disconnected` | The connection has been intentionally terminated. Triggered when user manually disconnects or unsubscribes. | 0.3.0 |
| `DisconnectedUnexpectedly(PubNubError)` | The connection was unexpectedly lost, with details about the error. This status includes the specific `PubNubError` that caused the disconnection. | 0.2.1 |
| `ConnectionError(PubNubError)` | Failed to establish the initial connection, with details about the error. This status includes the specific `PubNubError` that caused the connection failure. | 0.3.0 |

:::tip SDK connection lifecycle
The subscribe loop implementation in version 0.3.0 provides a more sophisticated state machine for handling connection statuses compared to earlier versions of the SDK. For more general information on statuses and reconnection policies, refer to [SDK Connection Lifecycle](https://www.pubnub.com/docs/general/setup/connection-management#sdk-connection-lifecycle).
:::

## Error handling

The Rust SDK provides detailed error information through the `PubNubError` type, which is included in the `ConnectionError` and `DisconnectedUnexpectedly` status variants.

### Common error types

Errors in the Rust SDK are structured as `PubNubError` instances, which provide:

* Error type classification
* Detailed error message
* Context information about the operation that failed
* Underlying cause when available

You can inspect the error details by pattern matching on the status variants that contain errors:

```rust
tokio::spawn(client.status_stream().for_each(|status| async move {
    match status {
        ConnectionStatus::ConnectionError(error) => {
            println!("Connection error: {:?}", error);
            // Handle connection error
        },
        ConnectionStatus::DisconnectedUnexpectedly(error) => {
            println!("Unexpected disconnection: {:?}", error);
            // Handle unexpected disconnection
        },
        // Handle other status types
        _ => {}
    }
}));
```

:::tip Subscription handling
You can access the status stream by calling `client.status_stream()` on your PubNub client instance. This returns a stream of `ConnectionStatus` events that you can observe in your application.
:::