holiday_lights/lights/src/lib.rs

27 lines
484 B
Rust

#![no_std]
pub mod gamma;
pub mod rgb;
use core::borrow::Borrow;
pub trait Lights {
type Pixel;
fn render(&mut self, pixel: &Self::Pixel);
fn latch(&mut self);
}
pub trait PixelIterator<T: Lights> {
fn render_to(&mut self, lights: &mut T);
}
impl<T: Lights, I: Iterator> PixelIterator<T> for I
where I::Item: Borrow<T::Pixel>
{
#[inline]
fn render_to(&mut self, lights: &mut T) {
self.for_each(|pixel| lights.render(pixel.borrow()));
}
}