-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support for passing async fn into advertise_service
#108
Comments
If you're blocked on this you still have the option of calling |
I think it is definitely something we'd like to support if possible. It shouldn't be too hard to try experimenting with our internal type erasure to see if this works, but I'm suspicious we're going to hit some limitation of |
@ssnover agreed - i think it would just be nicer overall though for the functions to be async in general though. @Carter12s - thanks, makes sense. let me take a look at it and I'll take a stab at it if it seems relatively not difficult. |
Having glanced at this for a bit, the main challenge is our paradigm around type erasure with the closure. Async closures are unstable, which means the If you look at implementing this: I'd recommend |
Update! Async closures have merged! rust-lang/rust#132706 We should be able to build this out once the next version of rust ships (could build it out on nightly right now). Once built we can put it behind a feature flag to not affect out min rust version too much. But super excited this is coming. |
Rust 1.85 is officially out with async closures are fully supported!!! We're ready to start work on this one. |
Do we have an established MSRV target? It's pretty common for the ecosystem to support current stable and the two previous versions. |
README currently calls out 1.75, but I don't think we've got that in the Cargo.tomls yet. My thought here is that we build this feature out under a feature flag ["async-closures"], and when ~1.87 drops we enable that feature as default. I'm open to opinions on the API, but it feels like it is worth keeping the non-async versions around? Have both |
In the
service_server.rs
example, I've noticed that there is:and
my_service
is a simplefn
here, but many services are often going to require async/await type functions to run within the function. Is there plan to support async fn here?If not, I'm happy to look into creating a PR to add support for this especially because I'd like to use async functions within my service callback that I pass in.
The text was updated successfully, but these errors were encountered: