actix / actix-web

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.
https://actix.rs
Apache License 2.0
21.33k stars 1.66k forks source link

Does actix web allow to use async await ? #1144

Closed LifeIsStrange closed 4 years ago

LifeIsStrange commented 4 years ago

The future state in rust is very confusing. We see in your TOML that you use future rs instead of futures-preview = { version = "=0.3.0-alpha.19", features = ["async-await"] }

So internally you can't use yet async await, but is this an implementation detail or does it propagate through the api and prevents end users to use async await in their actix web code ?

Moreover, you seems to use Future instead of the futures preview Future

Could you ELI5 the situation ? We use rust nightly BTW.

Finally, future preview once 0.3 stabilise will be renamed to future-rs and overwrite future rs codebase. It means you will be able to use async await internally, do you plan it ? Also, do you plan to switch to Future ?

fakeshadow commented 4 years ago

Yes it's allowed. futures-preivew have compat layer for futures 0.1 and it works on actix-web.

Migrate to std-future will eventually happen on almost all async related crates that are maintained. It takes time and effort to do so especially for big projects like actix-web.

JohnTitor commented 4 years ago

Also, we already have the issue of updating futures (#955). See also there.

JohnTitor commented 4 years ago

What is the purpose of this issue? If it's about futures, you can close this in favor of #955. And the examples for async can be found actix/examples.

LifeIsStrange commented 4 years ago

@fakeshadow Thanks, we will definitely try the compat layer then!

Hi @JohnTitor ! Thanks for the informations and the examples. I guess I can close the issue.

BTW, I can appreciate the fact that you appreciate steinsgate! How convenient to meet a time traveler on an issue talking about futures ;)

LifeIsStrange commented 4 years ago

@JohnTitor I wasn't able to find async/await syntax from the rust language examples in actix/examples. I looked at async_db, async_ex1, and async_ex2. They only show the custom syntax of ::to_async().