Add extra models to ledmodes

- Configurable anime example
- Gfx power states as enum

Closes #72
This commit is contained in:
Luke D Jones
2021-03-29 19:36:30 +13:00
parent fbc248177a
commit 7ff01f12e9
52 changed files with 2983 additions and 564 deletions

37
rog-anime/src/error.rs Normal file
View File

@@ -0,0 +1,37 @@
use std::error::Error;
use std::fmt;
use png_pong::decode::Error as PngError;
#[derive(Debug)]
pub enum AnimeError {
NoFrames,
Io(std::io::Error),
Png(PngError),
Format
}
impl fmt::Display for AnimeError {
// This trait requires `fmt` with this exact signature.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
AnimeError::NoFrames => write!(f, "No frames in PNG"),
AnimeError::Io(e) => write!(f, "Could not open: {}", e),
AnimeError::Png(e) => write!(f, "PNG error: {}", e),
AnimeError::Format => write!(f, "PNG file is not 8bit greyscale"),
}
}
}
impl Error for AnimeError {}
impl From<std::io::Error> for AnimeError {
fn from(err: std::io::Error) -> Self {
AnimeError::Io(err)
}
}
impl From<PngError> for AnimeError {
fn from(err: PngError) -> Self {
AnimeError::Png(err)
}
}