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

# Memory • Rust AI Agent SDK

> Memory: Memory manager for agents

# Memory

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

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

Memory manager for agents

## Fields

| Name      | Type                           | Description |
| --------- | ------------------------------ | ----------- |
| `adapter` | `Box&lt;dyn MemoryAdapter&gt;` | -           |
| `config`  | `MemoryConfig`                 | -           |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new(adapter: impl MemoryAdapter + 'static, config: MemoryConfig) -> Self
```

Create a new memory with the given adapter

**Parameters:**

| Name      | Type                           |
| --------- | ------------------------------ |
| `adapter` | `impl MemoryAdapter + 'static` |
| `config`  | `MemoryConfig`                 |

### `in_memory`

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

Create a new in-memory memory

**Parameters:**

| Name     | Type           |
| -------- | -------------- |
| `config` | `MemoryConfig` |

### `default_memory`

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

Create with default config

### `store`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn store(&mut self, message: Message) -> Result<()>
```

Store a message

**Parameters:**

| Name      | Type      |
| --------- | --------- |
| `message` | `Message` |

### `history`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn history(&self) -> Result<Vec<Message>>
```

Get conversation history

### `search`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn search(&self, query: &str, limit: usize) -> Result<Vec<Message>>
```

Search memory

**Parameters:**

| Name    | Type    |
| ------- | ------- |
| `query` | `&str`  |
| `limit` | `usize` |

### `clear`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn clear(&mut self) -> Result<()>
```

Clear memory

### `config`

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

Get the config

## Source

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

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Memory" icon="database" href="/docs/rust/memory" />

  <Card title="Rust Sessions" icon="clock" href="/docs/rust/sessions" />

  <Card title="Rust Knowledge" icon="book" href="/docs/rust/knowledge" />
</CardGroup>
