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

Async trait #12

Open
davoclavo opened this issue May 29, 2024 · 1 comment
Open

Async trait #12

davoclavo opened this issue May 29, 2024 · 1 comment

Comments

@davoclavo
Copy link

Hello! I was wondering if there is interest in adding a trait for async drivers.

I am currently using an Rmt async driver for my smart leds and couldn't find support for it anywhere, so I rolled my own, and wanted to contribute back.

I am happy to provide a PR to enable those traits (perhaps with a feature flag) something like the following, or perhaps via a generic type, as esp-hal does it

#[cfg(feature = "async")]
pub trait SmartLedsWriteAsync {
    type Error;
    type Color;
    async fn write<T, I>(&mut self, iterator: T) -> Result<(), Self::Error>
    where
        T: IntoIterator<Item = I>,
        I: Into<Self::Color>;
}
@david-sawatzke
Copy link
Collaborator

I wouldn't be against it, but, to be honest, I have very little experience with async rust. Feel free to open a PR.

Since I don't have any idea about async, let me ask a few questions:

  • Is there a reason to hide it behind a feature flag? Could it lead to issues if enabled in some circumstances?
  • If both traits (the async and the non-async one) are in scope, could this lead to conflicts due to sharing the same name? Or is the context almost always enough to select the correct one? How do other crates with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants