---
title: BodyExt
summary: Extensions to the crate::http::body::Body type to support trailers.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/experimental/trait.BodyExt/
---

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

```rust
pub trait BodyExt {
    // Required methods
    fn append_trailer(
        &mut self,
        name: impl ToHeaderName,
        value: impl ToHeaderValue,
    );
    fn get_trailers(&mut self) -> Result<HeaderMap, Error>;
}
```

Extensions to the [`crate::http::body::Body`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/) type to support trailers.

## Methods

### append_trailer

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/experimental.rs#489

```rust
fn append_trailer(&mut self, name: impl ToHeaderName, value: impl ToHeaderValue)
```

Append the given trailer name and value to this body.

Trailers will be sent once the body send is complete. This function will not
discard any existing values for the trailer; this value will simply be appended
to the set of existing values.
#### Stability

This is part of an experimental API that is subject to change or removal even in minor versions of
this crate.

**Parameters**

- `self`: `&mut Self`
- `name`: `impl ToHeaderName`
- `value`: `impl ToHeaderValue`

### get_trailers

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/experimental.rs#501

```rust
fn get_trailers(&mut self) -> Result<HeaderMap, Error>
```

Get the trailers associated with this body.

Note that modifying this [`HeaderMap`](https://docs.rs/http/latest/http/header/map/struct.HeaderMap.html) will have no effect on the trailers
for the body; in order to add trailers, you will need to use [`BodyExt::append_trailer`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/experimental/trait.BodyExt/#method-append_trailer).
If you need to remove a trailer, the only current mechanism to do so is to
create a fresh body, and then copy over the trailers you wish to maintain.
(If this inconvenient, please contact your Fastly support team, and mention
this shortcoming.)
#### Trailers

Trailers can be tricky to access. You must completely read all bytes from the body
before calling this function. The outermost `Result` reflects this requirement; if you
receive [`BodyHandleError::TrailersNotReady`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/experimental/enum.BodyHandleError/), there are potentially more bytes available
in the body that you must read.
#### Stability

This is part of an experimental API that is subject to change or removal even in minor versions of
this crate.

**Parameters**

- `self`: `&mut Self`

**Returns**

`Result<HeaderMap, Error>`
