---
title: PendingTransaction
summary: A cache transaction suspended between lookup and response.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.PendingTransaction/
---

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

```rust
pub struct PendingTransaction { /* private fields */ }
```

A cache transaction suspended between lookup and response.

This handle is produced by [`TransactionLookupBuilder::execute_async()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.TransactionLookupBuilder/#method-execute_async).

## Blocking Status

Callers can check whether or not the request was instructed to wait behind
another caller by calling [`PendingTransaction::pending()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.PendingTransaction/#method-pending), and can complete
the request (returning a [`Transaction`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Transaction/)) by calling [`PendingTransaction::wait()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.PendingTransaction/#method-wait).

## Methods

### pending

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#239

```rust
fn pending(&self) -> Result<bool, CacheError>
```

Returns `true` if this request was instructed to wait for another request
to insert the looked-up item, and `false` otherwise.

Note that, even if [`pending()`](`PendingTransaction::pending()`) returns
`true`, the [`Transaction`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Transaction/) returned by [`wait()`](`PendingTransaction::wait()`) may
still be required to insert (or update) the object. This can happen if
the caller providng the item called [`Transaction::cancel_insert_or_update()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Transaction/#method-cancel_insert_or_update)
or encountered an error.

**Parameters**

- `self`: `&Self`

**Returns**

`Result<bool, CacheError>`

### wait

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#250

```rust
fn wait(self) -> Result<Transaction, CacheError>
```

Returns the [`Transaction`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Transaction/) resulting from the lookup that produced this
[`PendingTransaction`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.PendingTransaction/), waiting for another caller to provide the requested item
if necessary.

If a timeout was set via [`TransactionLookupBuilder::timeout()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.TransactionLookupBuilder/#method-timeout), this call returns
[`CacheError::Timeout`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/enum.CacheError/) if another caller does not provide the item within the timeout; see
[`wait_for()`](`PendingTransaction::wait_for()`) for the timeout semantics.

**Parameters**

- `self`: `Self`

**Returns**

`Result<Transaction, CacheError>`

### wait_for

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#266

```rust
fn wait_for(self, timeout: Duration) -> Result<Transaction, CacheError>
```

Like [`wait()`](`PendingTransaction::wait()`), but gives up after `timeout` and returns
[`CacheError::Timeout`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/enum.CacheError/) if the lookup has not resolved by then. The `timeout` argument
overrides any timeout set via [`TransactionLookupBuilder::timeout()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.TransactionLookupBuilder/#method-timeout).

This bounds the time spent blocking for another caller to provide the requested item under
request collapsing. It is useful when a slow or wedged caller would otherwise block this
lookup: rather than blocking, the caller can time out and decide how to proceed (for
example, by bypassing the cache and going directly to origin).

On timeout, the wait is abandoned and the lookup's resources are released; this
[`PendingTransaction`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.PendingTransaction/) is consumed regardless of the outcome.

**Parameters**

- `self`: `Self`
- `timeout`: `Duration`

**Returns**

`Result<Transaction, CacheError>`

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