Skip to content

Commit

Permalink
Implement FrameBufferBackend for slice
Browse files Browse the repository at this point in the history
  • Loading branch information
jounathaen committed Mar 27, 2024
1 parent 4205fb2 commit f609f2e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/backends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ impl<C: PixelColor, const N: usize> FrameBufferBackend for [C; N] {
}
}

/// Warning, this can panic, if the assumed size of the framebuffer (widht * height) is larger than the slice.
impl<C: PixelColor> FrameBufferBackend for &mut [C] {
type Color = C;
fn set(&mut self, index: usize, color: C) {
self[index] = color
}

fn get(&self, index: usize) -> C {
self[index]
}

fn nr_elements(&self) -> usize {
self.len()
}
}

/// Backends implementing this Trait can be used for DMA.
///
/// # Safety
Expand Down

0 comments on commit f609f2e

Please sign in to comment.