> ## 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.

# Context Segment • Rust AI Agent SDK

> ContextSegment: A segment of context with token count.

# ContextSegment

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

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

A segment of context with token count.

## Fields

| Name       | Type                   | Description                        |
| ---------- | ---------------------- | ---------------------------------- |
| `name`     | `String`               | Segment name/type                  |
| `tokens`   | `usize`                | Token count for this segment       |
| `priority` | `i32`                  | Priority (higher = more important) |
| `content`  | `Option&lt;String&gt;` | Content of the segment             |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new(name: impl Into<String>, tokens: usize) -> Self
```

Create a new context segment

**Parameters:**

| Name     | Type                      |
| -------- | ------------------------- |
| `name`   | `impl Into&lt;String&gt;` |
| `tokens` | `usize`                   |

### `priority`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn priority(mut self, priority: i32) -> Self
```

Set priority

**Parameters:**

| Name       | Type  |
| ---------- | ----- |
| `priority` | `i32` |

### `content`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn content(mut self, content: impl Into<String>) -> Self
```

Set content

**Parameters:**

| Name      | Type                      |
| --------- | ------------------------- |
| `content` | `impl Into&lt;String&gt;` |

## Source

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

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Context Management" icon="layer-group" href="/docs/rust/context-management" />

  <Card title="Rust Token Management" icon="coins" href="/docs/rust/token-management" />
</CardGroup>
