Cause great pain to self with cargo-deny + cargo-cranky

This commit is contained in:
Luke D. Jones
2022-12-04 21:49:47 +13:00
parent 2fca7a09c4
commit 2705b08dca
60 changed files with 622 additions and 339 deletions

View File

@@ -25,7 +25,6 @@ impl From<u32> for LedBrightness {
match bright {
0 => LedBrightness::Off,
1 => LedBrightness::Low,
2 => LedBrightness::Med,
3 => LedBrightness::High,
_ => LedBrightness::Med,
}
@@ -179,21 +178,7 @@ impl Display for AuraModeNum {
impl From<AuraModeNum> for String {
fn from(mode: AuraModeNum) -> Self {
match mode {
AuraModeNum::Static => "Static",
AuraModeNum::Breathe => "Breathe",
AuraModeNum::Strobe => "Strobe",
AuraModeNum::Rainbow => "Rainbow",
AuraModeNum::Star => "Stars",
AuraModeNum::Rain => "Rain",
AuraModeNum::Highlight => "Highlight",
AuraModeNum::Laser => "Laser",
AuraModeNum::Ripple => "Ripple",
AuraModeNum::Pulse => "Pulse",
AuraModeNum::Comet => "Comet",
AuraModeNum::Flash => "Flash",
}
.to_string()
<&str>::from(&mode).to_owned()
}
}
@@ -218,7 +203,6 @@ impl From<&AuraModeNum> for &str {
impl From<&str> for AuraModeNum {
fn from(mode: &str) -> Self {
match mode {
"Static" => AuraModeNum::Static,
"Breathe" => AuraModeNum::Breathe,
"Strobe" => AuraModeNum::Strobe,
"Rainbow" => AuraModeNum::Rainbow,
@@ -238,7 +222,6 @@ impl From<&str> for AuraModeNum {
impl From<u8> for AuraModeNum {
fn from(mode: u8) -> Self {
match mode {
0 => AuraModeNum::Static,
1 => AuraModeNum::Breathe,
2 => AuraModeNum::Strobe,
3 => AuraModeNum::Rainbow,
@@ -284,22 +267,14 @@ impl FromStr for AuraZone {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let s = s.to_lowercase();
match s.to_ascii_lowercase().as_str() {
"0" => Ok(AuraZone::None),
"none" => Ok(AuraZone::None),
"1" => Ok(AuraZone::Key1),
"one" => Ok(AuraZone::Key1),
"2" => Ok(AuraZone::Key2),
"two" => Ok(AuraZone::Key2),
"3" => Ok(AuraZone::Key3),
"three" => Ok(AuraZone::Key3),
"4" => Ok(AuraZone::Key4),
"four" => Ok(AuraZone::Key4),
"5" => Ok(AuraZone::Logo),
"logo" => Ok(AuraZone::Logo),
"6" => Ok(AuraZone::BarLeft),
"lightbar-left" => Ok(AuraZone::BarLeft),
"7" => Ok(AuraZone::BarRight),
"lightbar-right" => Ok(AuraZone::BarRight),
"0" | "none" => Ok(AuraZone::None),
"1" | "one" => Ok(AuraZone::Key1),
"2" | "two" => Ok(AuraZone::Key2),
"3" | "three" => Ok(AuraZone::Key3),
"4" | "four" => Ok(AuraZone::Key4),
"5" | "logo" => Ok(AuraZone::Logo),
"6" | "lightbar-left" => Ok(AuraZone::BarLeft),
"7" | "lightbar-right" => Ok(AuraZone::BarRight),
_ => Err(Error::ParseSpeed),
}
}
@@ -395,18 +370,20 @@ impl AuraEffect {
/// factory mode accepts only one colour.
pub const fn allowed_parameters(mode: AuraModeNum) -> AuraParameters {
match mode {
AuraModeNum::Static => AuraParameters::new(true, true, false, false, false),
AuraModeNum::Static
| AuraModeNum::Highlight
| AuraModeNum::Pulse
| AuraModeNum::Comet
| AuraModeNum::Flash => AuraParameters::new(true, true, false, false, false),
AuraModeNum::Breathe => AuraParameters::new(true, true, true, true, false),
AuraModeNum::Strobe => AuraParameters::new(true, false, false, true, false),
AuraModeNum::Strobe | AuraModeNum::Rain => {
AuraParameters::new(true, false, false, true, false)
}
AuraModeNum::Rainbow => AuraParameters::new(true, false, false, true, true),
AuraModeNum::Star => AuraParameters::new(true, true, true, true, true),
AuraModeNum::Rain => AuraParameters::new(true, false, false, true, false),
AuraModeNum::Highlight => AuraParameters::new(true, true, false, false, false),
AuraModeNum::Laser => AuraParameters::new(true, true, false, true, false),
AuraModeNum::Ripple => AuraParameters::new(true, true, false, true, false),
AuraModeNum::Pulse => AuraParameters::new(true, true, false, false, false),
AuraModeNum::Comet => AuraParameters::new(true, true, false, false, false),
AuraModeNum::Flash => AuraParameters::new(true, true, false, false, false),
AuraModeNum::Laser | AuraModeNum::Ripple => {
AuraParameters::new(true, true, false, true, false)
}
}
}
}

View File

@@ -13,7 +13,7 @@ pub enum Error {
impl fmt::Display for Error {
// This trait requires `fmt` with this exact signature.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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"),

View File

@@ -139,17 +139,17 @@ impl From<&Key> for &str {
Key::MediaStop => "Media Stop",
Key::MediaNext => "Media Next",
Key::MediaPrev => "Media Previous",
Key::NormalBlank => "",
Key::NormalSpacer => "",
Key::FuncBlank => "",
Key::FuncSpacer => "",
Key::ArrowBlank => "",
Key::ArrowSpacer => "",
Key::ArrowRegularBlank => "",
Key::ArrowRegularSpacer => "",
Key::ArrowSplitBlank => "",
Key::ArrowSplitSpacer => "",
Key::RowEndSpacer => "",
Key::NormalBlank
| Key::NormalSpacer
| Key::FuncBlank
| Key::FuncSpacer
| Key::ArrowBlank
| Key::ArrowSpacer
| Key::ArrowRegularBlank
| Key::ArrowRegularSpacer
| Key::ArrowSplitBlank
| Key::ArrowSplitSpacer
| Key::RowEndSpacer => "",
}
}
}

View File

@@ -203,17 +203,22 @@ pub enum KeyShape {
impl KeyShape {
pub const fn width(&self) -> f32 {
match self {
Self::Tilde => 0.8,
Self::Normal => 1.0,
Self::NormalBlank => 1.0,
Self::NormalSpacer => 1.0,
Self::Func => 1.0,
Self::FuncBlank => 1.0,
Self::Tilde | Self::Arrow => 0.8,
Self::Normal
| Self::NormalBlank
| Self::NormalSpacer
| Self::Func
| Self::FuncBlank
| Self::Space5
| Self::ArrowBlank
| Self::ArrowSpacer
| Self::ArrowSplit
| Self::ArrowSplitBlank
| Self::ArrowSplitSpacer => 1.0,
Self::FuncSpacer => 0.6,
Self::Space => 5.0,
Self::Space5 => 1.0,
Self::LCtrlMed => 1.1,
Self::LShift => 2.0,
Self::LShift | Self::Backspace => 2.0,
Self::LShift3 => 0.67,
Self::RShift => 2.8,
Self::RshiftSmall => 1.8,
@@ -222,12 +227,9 @@ impl KeyShape {
Self::Return3 => 0.7333,
Self::Tab => 1.4,
Self::Caps => 1.6,
Self::Backspace => 2.0,
Self::Backspace3 => 0.666,
Self::ArrowRegularBlank | Self::ArrowRegularSpacer => 0.7,
Self::Arrow => 0.8,
Self::ArrowBlank | Self::ArrowSpacer => 1.0,
Self::ArrowSplit | Self::ArrowSplitBlank | Self::ArrowSplitSpacer => 1.0,
Self::RowEndSpacer => 0.1,
}
}

View File

@@ -6,7 +6,7 @@ impl KeyLayout {
pub fn g513_layout() -> Self {
Self {
matches: vec!["G513".into()],
locale: "US".to_string(),
locale: "US".to_owned(),
rows: vec![
KeyRow::new(
0.8,

View File

@@ -5,7 +5,7 @@ impl KeyLayout {
pub fn ga401_layout() -> Self {
Self {
matches: vec!["GA401".into(), "GA402".into()],
locale: "US".to_string(),
locale: "US".to_owned(),
rows: vec![
KeyRow::new(
0.8,

View File

@@ -5,7 +5,7 @@ impl KeyLayout {
pub fn gx502_layout() -> Self {
Self {
matches: vec!["GX502".into(), "GU502".into()],
locale: "US".to_string(),
locale: "US".to_owned(),
rows: vec![
KeyRow::new(
0.8,

View File

@@ -43,7 +43,7 @@ impl KeyLayout {
pub fn matches(&self, board_name: &str) -> bool {
let board = board_name.to_ascii_uppercase();
for tmp in self.matches.iter() {
for tmp in &self.matches {
if board.contains(tmp.as_str()) {
return true;
}
@@ -91,7 +91,7 @@ impl KeyRow {
Self { height, row }
}
pub fn row(&self) -> Iter<Key> {
pub fn row(&self) -> Iter<'_, Key> {
self.row.iter()
}

View File

@@ -43,8 +43,7 @@ impl ZonedColourArray {
pub fn rgb_for_zone(&mut self, zone: PerZone) -> &mut [u8] {
match zone {
PerZone::None => &mut self.0[9..=11],
PerZone::KeyboardLeft => &mut self.0[9..=11],
PerZone::None | PerZone::KeyboardLeft => &mut self.0[9..=11],
PerZone::KeyboardCenterLeft => &mut self.0[12..=14],
PerZone::KeyboardCenterRight => &mut self.0[15..=17],
PerZone::KeyboardRight => &mut self.0[18..=20],

View File

@@ -9,7 +9,7 @@ use serde_derive::{Deserialize, Serialize};
// static mut RNDINDEX: usize = 0;
static mut PRNDINDEX: usize = 0;
/// Pseudo random table ripped straight out of Room4Doom
/// Pseudo random table ripped straight out of room4doom
pub const RNDTABLE: [i32; 256] = [
0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66, 74, 21, 211, 47, 80, 242, 154,
27, 205, 128, 161, 89, 77, 36, 95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188,
@@ -88,7 +88,7 @@ impl Sequences {
}
pub fn next_state(&mut self, layout: &KeyLayout) {
for effect in self.0.iter_mut() {
for effect in &mut self.0 {
effect.next_state(layout);
}
}
@@ -97,7 +97,7 @@ impl Sequences {
let mut keys = KeyColourArray::new();
let mut zones = ZonedColourArray::new();
let mut is_per_key = false;
for effect in self.0.iter() {
for effect in &self.0 {
match effect.get_led_type() {
LedType::Key(key) => {
is_per_key = true;

View File

@@ -36,14 +36,10 @@ impl From<&str> for AuraDevice {
fn from(s: &str) -> Self {
match s.to_lowercase().as_str() {
"tuf" => AuraDevice::Tuf,
"1866" => AuraDevice::X1866,
"1869" => AuraDevice::X1869,
"1854" => AuraDevice::X1854,
"19b6" => AuraDevice::X19B6,
"0x1866" => AuraDevice::X1866,
"0x1869" => AuraDevice::X1869,
"0x1854" => AuraDevice::X1854,
"0x19b6" => AuraDevice::X19B6,
"1866" | "0x1866" => AuraDevice::X1866,
"1869" | "0x1869" => AuraDevice::X1869,
"1854" | "0x1854" => AuraDevice::X1854,
"19b6" | "0x19b6" => AuraDevice::X19B6,
_ => AuraDevice::Unknown,
}
}
@@ -108,9 +104,9 @@ impl From<AuraDev1866> for u32 {
impl AuraDev1866 {
pub fn to_bytes(control: &[Self]) -> [u8; 3] {
let mut a: u32 = 0;
control.iter().for_each(|n| {
for n in control {
a |= *n as u32;
});
}
[
((a & 0xff0000) >> 16) as u8,
((a & 0xff00) >> 8) as u8,
@@ -197,9 +193,9 @@ impl From<AuraDev19b6> for u32 {
impl AuraDev19b6 {
pub fn to_bytes(control: &[Self]) -> [u8; 3] {
let mut a: u32 = 0;
control.iter().for_each(|n| {
for n in control {
a |= *n as u32;
});
}
[
(a & 0xff) as u8,
((a & 0xff00) >> 8) as u8,