Polling keyboard in daemon. Split into app/lib

This commit is contained in:
Luke
2020-04-17 12:04:01 +12:00
parent 5f8ea365ef
commit e49799e4d2
16 changed files with 860 additions and 220 deletions

38
rog-lib/src/error.rs Normal file
View File

@@ -0,0 +1,38 @@
use std::error::Error;
use std::fmt;
use std::fmt::{Debug, Display};
#[derive(PartialEq)]
pub enum AuraError {
ParseColour,
ParseSpeed,
ParseDirection,
ParseBrightness,
PollKeyboard,
}
impl Debug for AuraError {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Display::fmt(self.description(), f)
}
}
impl Display for AuraError {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Display::fmt(self.description(), f)
}
}
impl Error for AuraError {
fn description(&self) -> &str {
match self {
AuraError::ParseColour => "could not parse colour",
AuraError::ParseSpeed => "could not parse speed",
AuraError::ParseDirection => "could not parse direction",
AuraError::ParseBrightness => "could not parse brightness",
AuraError::PollKeyboard => "failed to poll keyboard",
}
}
}