tower-rs / tower

async fn(Request) -> Result<Response, Error>
https://docs.rs/tower
MIT License
3.56k stars 281 forks source link

feat: enable non-'static where possible #765

Open Daniel-Aaron-Bloom opened 8 months ago

Daniel-Aaron-Bloom commented 8 months ago

Motivation

Currently, many tower service wrappers and layers are limited to working with 'static types, which limits its usefulness when working with non-statically borrowed things to and from scoped tasks (e.g. async-scoped).

Solution

Remove the 'static restrictions where possible, mostly by introducing lifetime parameters.

This change excludes Buffer and BufferLayer which are more difficult to make non-'static.

This PR replaces #732