smart-leds-rs / smart-leds-trait

A trait for implementing effects, modifiers and drivers for programmable leds
Apache License 2.0
1 stars 3 forks source link

Async trait #12

Open davoclavo opened 5 months ago

davoclavo commented 5 months ago

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 commented 3 months ago

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: