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

Proposal: shall we use async_fn_in_traits? #89

Open
PureWhiteWu opened this issue Nov 17, 2022 · 4 comments
Open

Proposal: shall we use async_fn_in_traits? #89

PureWhiteWu opened this issue Nov 17, 2022 · 4 comments
Labels
A-volo This issue concerns the main`volo` crate. C-question A user question. E-help-wanted Stuff where we want help.

Comments

@PureWhiteWu
Copy link
Member

PureWhiteWu commented Nov 17, 2022

Now that async_fn_in_traits has reached MVP in nightly, and will hopefully be stabilized in six months.

Shall we use that?

FYI:

  1. https://blog.rust-lang.org/inside-rust/2022/11/17/async-fn-in-trait-nightly.html
  2. Tracking Issue for async_fn_in_trait, return_position_impl_trait_in_trait rust-lang/rust#91611
@PureWhiteWu PureWhiteWu added A-volo This issue concerns the main`volo` crate. C-question A user question. E-help-wanted Stuff where we want help. labels Nov 17, 2022
@PureWhiteWu
Copy link
Member Author

I've tried this, but seems we have encountered the Send bound problem in volo.

I will try again some time later when this feature is more mature.

@my-vegetable-has-exploded
Copy link
Contributor

After using async_fn_in_traits, will we be able to provide msrv?

@PureWhiteWu
Copy link
Member Author

@my-vegetable-has-exploded Yes, this will be a breaking change, we are discussing and testing the new design.
Long story short, we are going to change Service to something like this:

pub trait Service<Cx, Request> {
 /// Responses given by the service.
 type Response;
 /// Errors produced by the service.
 type Error;
 /// Process the request and return the response asynchronously.
 fn call<'cx, 's>(&'s self, cx: &'cx mut Cx, req: Request) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send + 'cx
 where
 's: 'cx;
}

But we are not quite sure if this works fine, so we need some more tests.

@PureWhiteWu
Copy link
Member Author

We met this issue rust-lang/rust#100013 when migrating to rpitit, maybe we need to wait for this bug to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-volo This issue concerns the main`volo` crate. C-question A user question. E-help-wanted Stuff where we want help.
Development

No branches or pull requests

2 participants