---
title: LookupBuilder
summary: A builder for KVStore lookups, supporting advanced features like asynchronous execution.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.LookupBuilder/
---

**Kind:** Struct  
**Module:** [fastly](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/)  
**Package:** fastly 0.13.1  
**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/kv_store.rs#380

```rust
pub struct LookupBuilder<'a> { /* private fields */ }
```

A builder for KVStore lookups, supporting advanced features like asynchronous execution.

```rust
store.build_lookup()
   .execute("key1")?;
```

## Synchronous and Asynchronous support

LookupBuilder exposes the ability to issue an asynchronous lookup. Using
[`execute_async`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/kv_store/struct.LookupBuilder/#method-execute_async) will send the request, and unblock. There is currently no polling mechanism.
To retrieve the result, use the blocking function [`pending_lookup_wait`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/kv_store/struct.KVStore/#method-pending_lookup_wait).

## Examples

```rust
// synchronous non-builder lookup
let result: Result<LookupResponse, KVStoreError> = store.lookup("key");
// synchronous builder lookup
let result: Result<LookupResponse, KVStoreError> = store.build_lookup().execute("key");
// asynchronous builder lookup
let lookup_handle: Result<PendingLookupHandle, KVStoreError> = store.build_lookup().execute_async("key");
let result: Result<LookupResponse, KVStoreError> = store.pending_lookup_wait(lookup_handle?);
```

## Methods

### execute

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/kv_store.rs#388

```rust
fn execute(&self, key: &str) -> Result<LookupResponse, KVStoreError>
```

Initiate and wait on an lookup of a value in the KV Store.

Returns `Ok(LookupResponse)` if the value is retrieved without error, and `KVStoreError` if the lookup failed.

**Parameters**

- `self`: `&Self`
- `key`: `&str`

**Returns**

`Result<LookupResponse, KVStoreError>`

### execute_async

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/kv_store.rs#397

```rust
fn execute_async(&self, key: &str) -> Result<PendingLookupHandle, KVStoreError>
```

Initiate async lookup of a value in the KV Store.

Returns `Ok(Some(PendingLookupHandle))` if lookup creation is successful.

**Parameters**

- `self`: `&Self`
- `key`: `&str`

**Returns**

`Result<PendingLookupHandle, KVStoreError>`

## Auto trait implementations

- `Freeze`
- `RefUnwindSafe`
- `Send`
- `Sync`
- `Unpin`
- `UnsafeUnpin`
- `UnwindSafe`

## Blanket implementations

- `Any`
- `Borrow<T>`
- `BorrowMut<T>`
- `Downcast`
- `DowncastSync`
- `ErasedDestructor`
- `From<T>`
- `Into<U>`
- `IntoEither`
- `Same`
- `TryFrom<U>`
- `TryInto<U>`
