---
title: HandlerResult
summary: Trait for supporting more flexible return types for the handler passed to Serve::run.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/serve/trait.HandlerResult/
---

**Kind:** Trait  
**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#83

```rust
pub trait HandlerResult {
    type Error;

    // Required method
    fn send(self) -> Result<(), Self::Error>;
}
```

Trait for supporting more flexible return types for the handler passed to [Serve::run](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/serve/struct.Serve/#method-run).

The types that this is implemented for by default are:

- `Response`, for a handler that always generates a response.
- `()`, for a handler that has already called either [Response::send_to_client](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-send_to_client) or
  [Response::stream_to_client](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-stream_to_client).
- `Result<(), E>`, for a handler that has already called either [Response::send_to_client](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-send_to_client) or
  [Response::stream_to_client](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-stream_to_client), but might fail with an error of type `E` along the way.
- `Result<Response, E>`, for a handle the might generate a response to send or an error.

For the `Result` implementations, a return value containing an error will attempt to send
a 500 response status with a body containing the [ToString::to_string](https://doc.rust-lang.org/stable/alloc/string/ToString/fn.to_string.html) representation of the
error, in the same way that [fastly::main](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/attr.main/) does.

## Methods

### send

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

```rust
fn send(self) -> Result<(), Self::Error>
```

Perform any remaining work to send this response downstream.

**Parameters**

- `self`: `Self`

**Returns**

`Result<(), Self::Error>`
