-
Notifications
You must be signed in to change notification settings - Fork 42
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
Replace the crate async_trait with rust native support #1972
Comments
make sense |
@DmitryAstafyev Should I try to implement this in the CLI tool at first, or it's better to wait to make sure that there is no problem with forcing the minimum rust Version to be 1.75? |
@AmmarAbouZor hello. |
@DmitryAstafyev I thought it would some restriction because some developers in the team can't install rust Version 1.75, then they can't build either the app or the CLI-tool. |
So I've tried to apply the native async-trait on the CLI-tool and got some weird build error about cycles inside the traits, then I've tried to build it using rust nightly to get error messages which make sense: --> src/target.rs:48:30
|
48 | pub fn get(&self) -> Box<dyn Manager + Sync + Send> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ `Manager` cannot be made into an object
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> src/modules/mod.rs:78:14
|
61 | pub trait Manager {
| ------- this trait cannot be made into an object...
...
78 | async fn reset(&self) -> Result<SpawnResult, Error> {
| ^^^^^ ...because method `reset` is `async`
After reading the announcement of async traits in rust blog I've found out that dynamic dispatch still not supported with native rust. link. I think we can postpone this until there is a proper support for native async-traits in rust. @DmitryAstafyev Should we leave this issue open as reminder to check the progress of this issue with rust or we can just close it and open another once the native support is there? |
To Info: I could replace the async trait in the indexer project with the native async rust but we decided to postpone it for a little to make sure all build systems support rust version 1.75 |
From Rust1.75 onwards async support was added so we do not need async-trait crate anymore. Removed this crate in this PR and used native async support. Resolves: esrlabs#1972
@AmmarAbouZor sorry, I've missed your comment. Let's focus on CLI... this issue "linked" to @sudeeptarlekar. It's in the draft/research state and doesn't have hi-priority for now. |
Looks like doesn't make sense in the scope of current generation of chipmunk. I would close it. But with next generation of chipmunk we can think about design with native |
Prerequisites
affected version: Master
make sure to check this before filing an issue:
Describe what you would like to have
Native support for async traits has been added to rust form Version 1.75, which should be able to replace using the crate async_trait in the most cases, especially with a stand-alone application where no other apps have dependencies on the codes like with libraries to consider.
I want to try to replace the crate async_trait with the native rust solution, but at first I want to make sure that there are no problems to enforce the developers to use rust Version 1.75+.
Besides that we need to adjust the GitHub Pipelines to make sure that the latest rust version is installed
The text was updated successfully, but these errors were encountered: