> ## 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 Collector • Rust AI Agent SDK

> StreamCollector: Collects stream events and accumulated content.

# StreamCollector

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

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

Collects stream events and accumulated content.

## Fields

| Name      | Type                     | Description         |
| --------- | ------------------------ | ------------------- |
| `events`  | `Vec&lt;StreamEvent&gt;` | Collected events    |
| `content` | `String`                 | Accumulated content |
| `metrics` | `StreamMetrics`          | Metrics             |

## Methods

### `new`

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

Create a new collector

### `process`

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

Process an event

**Parameters:**

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

### `get_content`

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

Get final content

### `event_count`

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

Get event count

### `is_complete`

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

Check if streaming completed successfully

### `has_error`

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

Check if there was an error

### `get_error`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn get_error(&self) -> Option<&str>
```

Get error message if any

## Source

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