---
title: RequestPromise
summary: A promise of a future Request from a customer.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/serve/struct.RequestPromise/
---

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

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

A promise of a future Request from a customer.

When .wait() is called, this will resolve to either:
- a `Request`, if an additional user request has been assigned to this instance
- an `Error`, if:
  - The current `Request` has not been completed
  - A limit has been reached (number of requests per instance, timeout waiting for the next
  request)

## Methods

### new

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/serve.rs#514

```rust
fn new(reuse_settings: &NextRequestOptions) -> Result<RequestPromise, NextRequestError>
```

Create a new promise for receiving a subsequent downstream request.

**Parameters**

- `reuse_settings`: `&NextRequestOptions`

**Returns**

`Result<RequestPromise, NextRequestError>`

### wait

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/serve.rs#601

```rust
fn wait(self) -> Result<Request, NextRequestError>
```

Wait for the next request.

This returns if a next request is available; if an error occurs; or if the RequestPromise
exceeds its deadline.

**Parameters**

- `self`: `Self`

**Returns**

`Result<Request, NextRequestError>`

### wait_timeout

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/serve.rs#548

```rust
fn wait_timeout(self, timeout: Duration) -> Result<Request, NextRequestError>
```

Wait for the next request, up to the timeout provided here.

The timeout here represents how long this method waits, and not whether the handle
has become invalid. If a timeout of zero is provided, this acts as a poll-once, and
returns immediately with [NextRequestError::Timeout](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/serve/enum.NextRequestError/) if there is not a request ready.

Note that if the timeout is reached, this instance is still registered to receive a future
request; the RequestPromise can be recovered from the [NextRequestError::Timeout](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/serve/enum.NextRequestError/)
and another `wait_timeout` or `wait` call may be attempted on it.

If this instance needs to shut down, dropping the [RequestPromise](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/serve/struct.RequestPromise/) or
[NextRequestError](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/serve/enum.NextRequestError/) will abandon the promise and avoid queueing future requests for
the session.

Note that the timeout has an unspecified minimum resolution.
If a nonzero timeout smaller than the minimum resolution is provided, the time will be
rounded up to this resolution.

**Parameters**

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

**Returns**

`Result<Request, NextRequestError>`

## Trait implementations

### impl Debug for RequestPromise

#### fmt

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/serve.rs#414

```rust
fn fmt(&self, f: &mut Formatter<'_>) -> Result
```

**Parameters**

- `self`: `&Self`
- `f`: `&mut $crate::fmt::Formatter`

**Returns**

`$crate::fmt::Result`

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