1pub trait Pixel {
3 type BytesIter: Iterator<Item = u8>;
5
6 fn into_ws2812_bytes(self) -> Self::BytesIter;
10}
11
12impl Pixel for [u8; 3] {
14 type BytesIter = core::array::IntoIter<u8, 3>;
15
16 fn into_ws2812_bytes(self) -> Self::BytesIter {
17 [self[1], self[0], self[2]].into_iter()
19 }
20}
21
22impl Pixel for [u8; 4] {
24 type BytesIter = core::array::IntoIter<u8, 4>;
25
26 fn into_ws2812_bytes(self) -> Self::BytesIter {
27 self.into_iter()
28 }
29}
30
31impl Pixel for palette::LinSrgb<u8> {
40 type BytesIter = core::array::IntoIter<u8, 3>;
41
42 fn into_ws2812_bytes(self) -> Self::BytesIter {
43 [self.green, self.red, self.blue].into_iter()
44 }
45}
46
47impl<'a, P> Pixel for &'a P
48where
49 P: Pixel + Clone,
50{
51 type BytesIter = <P as Pixel>::BytesIter;
52 fn into_ws2812_bytes(self) -> Self::BytesIter {
53 self.clone().into_ws2812_bytes()
54 }
55}