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

# Knowledge Store Protocol • Rust AI Agent SDK

> KnowledgeStoreProtocol: Protocol for knowledge store backends.

# KnowledgeStoreProtocol

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

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

Protocol for knowledge store backends.

## Methods

### `search`

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

Search for relevant content

**Parameters:**

| Name       | Type                 |
| ---------- | -------------------- |
| `query`    | `&str`               |
| `user_id`  | `Option&lt;&str&gt;` |
| `agent_id` | `Option&lt;&str&gt;` |
| `limit`    | `usize`              |

### `add`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn add(
        &mut self,
        content: &str,
        user_id: Option<&str>,
        agent_id: Option<&str>,
        metadata: Option<HashMap<String, String>>,
    ) -> Result<AddResult>
```

Add content to the store

**Parameters:**

| Name       | Type                          |
| ---------- | ----------------------------- |
| `content`  | `&str`                        |
| `user_id`  | `Option&lt;&str&gt;`          |
| `agent_id` | `Option&lt;&str&gt;`          |
| `metadata` | `Option&lt;HashMap&lt;String` |

### `get`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn get(&self, item_id: &str) -> Result<Option<SearchResultItem>>
```

Get item by ID

**Parameters:**

| Name      | Type   |
| --------- | ------ |
| `item_id` | `&str` |

### `get_all`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn get_all(
        &self,
        user_id: Option<&str>,
        agent_id: Option<&str>,
        limit: usize,
    ) -> Result<SearchResult>
```

Get all items

**Parameters:**

| Name       | Type                 |
| ---------- | -------------------- |
| `user_id`  | `Option&lt;&str&gt;` |
| `agent_id` | `Option&lt;&str&gt;` |
| `limit`    | `usize`              |

### `update`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn update(&mut self, item_id: &str, content: &str) -> Result<AddResult>
```

Update an item

**Parameters:**

| Name      | Type   |
| --------- | ------ |
| `item_id` | `&str` |
| `content` | `&str` |

### `delete`

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

Delete an item

**Parameters:**

| Name      | Type   |
| --------- | ------ |
| `item_id` | `&str` |

### `delete_all`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn delete_all(&mut self, user_id: Option<&str>, agent_id: Option<&str>) -> Result<bool>
```

Delete all items

**Parameters:**

| Name       | Type                 |
| ---------- | -------------------- |
| `user_id`  | `Option&lt;&str&gt;` |
| `agent_id` | `Option&lt;&str&gt;` |

## Source

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

***

## Related Documentation

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

  <Card title="Rust Documents" icon="file-lines" href="/docs/rust/documents" />

  <Card title="Rust RAG" icon="magnifying-glass" href="/docs/rust/rag" />
</CardGroup>
