Skip to content

Commit 48019de

Browse files
Merge pull request #20 from Be-ing/no_mod
remove asynch module; move SmartLedsWriteAsync to top level
2 parents 7dbc764 + b787d41 commit 48019de

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "smart-leds-trait"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
authors = ["David Sawatzke <david-sawatzke@users.noreply.github.com>"]
55
edition = "2021"
66
categories = [
@@ -17,4 +17,4 @@ repository = "https://github.com/smart-leds-rs/smart-leds-trait"
1717
rgb = "0.8"
1818

1919
[features]
20-
serde = ["rgb/serde"]
20+
serde = ["rgb/serde"]

src/lib.rs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,26 @@ pub trait SmartLedsWrite {
3636
I: Into<Self::Color>;
3737
}
3838

39-
pub mod asynch {
40-
/// An async trait that Smart Led Drivers implement
41-
///
42-
/// The amount of time each iteration of `iterator` might take is undefined.
43-
/// Drivers, where this might lead to issues, aren't expected to work in all cases.
44-
pub trait SmartLedsWriteAsync {
45-
type Error;
46-
type Color;
47-
// The async_fn_in_trait warning doesn't really matter for embedded cases because
48-
// no_std async executors don't require futures to be Send. Also, embedded-hal-async
49-
// does not have Send bounds in its traits, so the HAL functions called in
50-
// implementations of this trait wouldn't return Send futures anyway. It's
51-
// questionable if it would be desirable for embedded HALs to return a Send future
52-
// for the write function for a peripheral because you probably don't want to
53-
// write data to the same peripheral from multiple threads simultaneously and have
54-
// the data get interleaved, nor have the embedded HAL implement a synchronization
55-
// mechanism with a run time cost to avoid that.
56-
// https://github.com/rust-embedded/embedded-hal/pull/515#issuecomment-1763525962
57-
#[allow(async_fn_in_trait)]
58-
async fn write<T, I>(&mut self, iterator: T) -> Result<(), Self::Error>
59-
where
60-
T: IntoIterator<Item = I>,
61-
I: Into<Self::Color>;
62-
}
39+
/// An async trait that Smart Led Drivers implement
40+
///
41+
/// The amount of time each iteration of `iterator` might take is undefined.
42+
/// Drivers, where this might lead to issues, aren't expected to work in all cases.
43+
pub trait SmartLedsWriteAsync {
44+
type Error;
45+
type Color;
46+
// The async_fn_in_trait warning doesn't really matter for embedded cases because
47+
// no_std async executors don't require futures to be Send. Also, embedded-hal-async
48+
// does not have Send bounds in its traits, so the HAL functions called in
49+
// implementations of this trait wouldn't return Send futures anyway. It's
50+
// questionable if it would be desirable for embedded HALs to return a Send future
51+
// for the write function for a peripheral because you probably don't want to
52+
// write data to the same peripheral from multiple threads simultaneously and have
53+
// the data get interleaved, nor have the embedded HAL implement a synchronization
54+
// mechanism with a run time cost to avoid that.
55+
// https://github.com/rust-embedded/embedded-hal/pull/515#issuecomment-1763525962
56+
#[allow(async_fn_in_trait)]
57+
async fn write<T, I>(&mut self, iterator: T) -> Result<(), Self::Error>
58+
where
59+
T: IntoIterator<Item = I>,
60+
I: Into<Self::Color>;
6361
}

0 commit comments

Comments
 (0)