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

# Stream Handler • Rust AI Agent SDK

> StreamHandler: Handler for managing stream callbacks.

# StreamHandler

> Defined in the [**streaming**](../modules/streaming) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Handler for managing stream callbacks.

## Fields

| Name        | Type                                       | Description |
| ----------- | ------------------------------------------ | ----------- |
| `callbacks` | `Vec&lt;Box&lt;dyn StreamCallback&gt;&gt;` | -           |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new() -> Self
```

Create a new stream handler

### `add_callback`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn add_callback(&mut self, callback: impl StreamCallback + 'static) -> ()
```

Add a callback

**Parameters:**

| Name       | Type                            |
| ---------- | ------------------------------- |
| `callback` | `impl StreamCallback + 'static` |

### `emit`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn emit(&self, event: &StreamEvent) -> ()
```

Emit an event to all callbacks

**Parameters:**

| Name    | Type           |
| ------- | -------------- |
| `event` | `&StreamEvent` |

### `callback_count`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn callback_count(&self) -> usize
```

Get callback count

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/streaming/mod.rs#L390">
  `praisonai/src/streaming/mod.rs` at line 390
</Card>
