Skip to content

Commit 2b6efa2

Browse files
david-sawatzkesajattack
authored andcommitted
Add async trait
Alternative to #13
1 parent 9d16d9e commit 2b6efa2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/lib.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct White<C>(pub C);
2323
pub type RGBW<ComponentType, WhiteComponentType = ComponentType> =
2424
RGBA<ComponentType, White<WhiteComponentType>>;
2525

26-
/// A trait that smart led drivers implement
26+
/// A trait that Smart Led Drivers implement
2727
///
2828
/// The amount of time each iteration of `iterator` might take is undefined.
2929
/// Drivers, where this might lead to issues, aren't expected to work in all cases.
@@ -35,3 +35,20 @@ pub trait SmartLedsWrite {
3535
T: IntoIterator<Item = I>,
3636
I: Into<Self::Color>;
3737
}
38+
39+
pub mod asynch {
40+
use core::future::Future;
41+
42+
/// An async trait that Smart Led Drivers implement
43+
///
44+
/// The amount of time each iteration of `iterator` might take is undefined.
45+
/// Drivers, where this might lead to issues, aren't expected to work in all cases.
46+
pub trait SmartLedsWrite {
47+
type Error;
48+
type Color;
49+
fn write<T, I>(&mut self, iterator: T) -> impl Future<Output = Result<(), Self::Error>>
50+
where
51+
T: IntoIterator<Item = I>,
52+
I: Into<Self::Color>;
53+
}
54+
}

0 commit comments

Comments
 (0)