Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Pin<Box<dyn Future>> from FromRequest implementations #2238

Open
hlbarber opened this issue Jan 20, 2023 · 2 comments
Open

Remove Pin<Box<dyn Future>> from FromRequest implementations #2238

hlbarber opened this issue Jan 20, 2023 · 2 comments
Labels
refactoring Changes that do not affect our users, mostly focused on maintainability server Rust server SDK

Comments

@hlbarber
Copy link
Contributor

hlbarber commented Jan 20, 2023

At the time of writing FromRequest::Future implementations are Pin<Box<dyn Future>>. By hand crafting a Future to get a concrete type we should be able to remove this heap allocation. This might involve rewriting https://docs.rs/hyper/latest/hyper/body/fn.to_bytes.html to give it a named type.

Support for async fn in traits might also be sufficient.

@hlbarber hlbarber added the server Rust server SDK label Jan 20, 2023
@hlbarber
Copy link
Contributor Author

Preemptively newtyping Pin<Box<dyn Future>> would also reduce breakage in the future, even without the rewrite of to_bytes.

@hlbarber
Copy link
Contributor Author

hlbarber commented Jan 20, 2023

As part of the migration from the old pre-1.0 hyper ecosystem, the HttpBody trait has evolved to a new, more versatile interface, this includes a rewrite of the surrounding utilities.

https://docs.rs/http-body-util/0.1.0-rc.2/http_body_util/combinators/struct.Collect.html

Context can be found here hyperium/hyper#3111 (comment)

This is a named Future which we can use to construct the associated type.

@hlbarber hlbarber added the refactoring Changes that do not affect our users, mostly focused on maintainability label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Changes that do not affect our users, mostly focused on maintainability server Rust server SDK
Projects
None yet
Development

No branches or pull requests

1 participant