diff --git a/Cargo.toml b/Cargo.toml index 8d6166e..63794f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "smart-leds-trait" -version = "0.3.0" +version = "0.4.0" authors = ["David Sawatzke "] edition = "2021" categories = [ @@ -17,4 +17,4 @@ repository = "https://github.com/smart-leds-rs/smart-leds-trait" rgb = "0.8" [features] -serde = ["rgb/serde"] \ No newline at end of file +serde = ["rgb/serde"] diff --git a/src/lib.rs b/src/lib.rs index 8ea9797..da40e6e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,28 +36,26 @@ pub trait SmartLedsWrite { I: Into; } -pub mod asynch { - /// An async trait that Smart Led Drivers implement - /// - /// The amount of time each iteration of `iterator` might take is undefined. - /// Drivers, where this might lead to issues, aren't expected to work in all cases. - pub trait SmartLedsWriteAsync { - type Error; - type Color; - // The async_fn_in_trait warning doesn't really matter for embedded cases because - // no_std async executors don't require futures to be Send. Also, embedded-hal-async - // does not have Send bounds in its traits, so the HAL functions called in - // implementations of this trait wouldn't return Send futures anyway. It's - // questionable if it would be desirable for embedded HALs to return a Send future - // for the write function for a peripheral because you probably don't want to - // write data to the same peripheral from multiple threads simultaneously and have - // the data get interleaved, nor have the embedded HAL implement a synchronization - // mechanism with a run time cost to avoid that. - // https://github.com/rust-embedded/embedded-hal/pull/515#issuecomment-1763525962 - #[allow(async_fn_in_trait)] - async fn write(&mut self, iterator: T) -> Result<(), Self::Error> - where - T: IntoIterator, - I: Into; - } +/// An async trait that Smart Led Drivers implement +/// +/// The amount of time each iteration of `iterator` might take is undefined. +/// Drivers, where this might lead to issues, aren't expected to work in all cases. +pub trait SmartLedsWriteAsync { + type Error; + type Color; + // The async_fn_in_trait warning doesn't really matter for embedded cases because + // no_std async executors don't require futures to be Send. Also, embedded-hal-async + // does not have Send bounds in its traits, so the HAL functions called in + // implementations of this trait wouldn't return Send futures anyway. It's + // questionable if it would be desirable for embedded HALs to return a Send future + // for the write function for a peripheral because you probably don't want to + // write data to the same peripheral from multiple threads simultaneously and have + // the data get interleaved, nor have the embedded HAL implement a synchronization + // mechanism with a run time cost to avoid that. + // https://github.com/rust-embedded/embedded-hal/pull/515#issuecomment-1763525962 + #[allow(async_fn_in_trait)] + async fn write(&mut self, iterator: T) -> Result<(), Self::Error> + where + T: IntoIterator, + I: Into; }