Partial daemon mode for builtin LED control

This commit is contained in:
Luke
2020-04-16 15:26:13 +12:00
parent 0d5341e003
commit 2d4953d87b
10 changed files with 265 additions and 63 deletions

36
src/error.rs Normal file
View File

@@ -0,0 +1,36 @@
use std::error::Error;
use std::fmt;
use std::fmt::{Debug, Display};
#[derive(PartialEq)]
pub(crate) enum AuraError {
ParseColour,
ParseSpeed,
ParseDirection,
ParseBrightness,
}
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",
}
}
}