mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
e99d8766fc
This also removes shell completitions as these are not maintained.
41 lines
1.0 KiB
Rust
41 lines
1.0 KiB
Rust
use std::error;
|
|
use std::fmt;
|
|
|
|
#[derive(Debug)]
|
|
pub enum Error {
|
|
ParseColour,
|
|
ParseSpeed,
|
|
ParseDirection,
|
|
ParseBrightness,
|
|
Io(std::io::Error),
|
|
Toml(toml::de::Error),
|
|
}
|
|
|
|
impl fmt::Display for Error {
|
|
// This trait requires `fmt` with this exact signature.
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
match self {
|
|
Error::ParseColour => write!(f, "Could not parse colour"),
|
|
Error::ParseSpeed => write!(f, "Could not parse speed"),
|
|
Error::ParseDirection => write!(f, "Could not parse direction"),
|
|
Error::ParseBrightness => write!(f, "Could not parse brightness"),
|
|
Error::Io(io) => write!(f, "IO Error: {io}"),
|
|
Error::Toml(e) => write!(f, "TOML Parse Error: {e}"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl error::Error for Error {}
|
|
|
|
impl From<std::io::Error> for Error {
|
|
fn from(e: std::io::Error) -> Self {
|
|
Self::Io(e)
|
|
}
|
|
}
|
|
|
|
impl From<toml::de::Error> for Error {
|
|
fn from(e: toml::de::Error) -> Self {
|
|
Self::Toml(e)
|
|
}
|
|
}
|