diff --git a/src/color.rs b/src/color.rs index b4f7918..4bcd0d4 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,7 +1,7 @@ use hex; +use serde::Deserialize; use std::num::ParseIntError; use std::str::FromStr; -use serde::Deserialize; #[derive(Copy, Clone, Debug, PartialEq, Deserialize)] pub struct Rgb(pub u8, pub u8, pub u8); diff --git a/src/pattern.rs b/src/pattern.rs index a3047b3..ffc11e8 100644 --- a/src/pattern.rs +++ b/src/pattern.rs @@ -20,11 +20,11 @@ enum PatternParameters { } pub enum PatternParameters { - Collide(Rgb,Rgb,Rgb), + Collide(Rgb, Rgb, Rgb), Fade(Rgb), MovingPixel(Rgb), MovingRainbow(u8, bool), - Orb(Rgb, u8,u8), + Orb(Rgb, u8, u8), Solid(Rgb), } diff --git a/src/webui.rs b/src/webui.rs index 4ec720c..b580384 100644 --- a/src/webui.rs +++ b/src/webui.rs @@ -2,13 +2,13 @@ use crate::color::Rgb; use crate::pattern; use crate::strip; use actix_web::web::Form; -use actix_web::{get, post, web, App, HttpRequest, HttpServer, Responder, Result, }; +use actix_web::{get, post, web, App, HttpRequest, HttpServer, Responder, Result}; // use actix_web::error::InternalError; use rust_embed::RustEmbed; use serde::Deserialize; +use std::io; use std::str::FromStr; use std::sync::{Arc, Mutex}; -use std::io; use std::sync::mpsc::Sender; @@ -28,18 +28,28 @@ struct AppState { // } #[post("/setcolor")] -async fn set_color(data: web::Data, params: web::Json) -> Result { +async fn set_color( + data: web::Data, + params: web::Json, +) -> Result { println!("{:?}", params); let pattern = match params.0 { - PatternParameters::Collide(l, r, c) => pattern::Collide::new(l,r,c) + PatternParameters::Collide(l, r, c) => pattern::Collide::new(l, r, c), }; data.strip_tx - .lock().or(Err(io::Error::new(io::ErrorKind::Other, "Failed to get a lock")))? + .lock() + .or(Err(io::Error::new( + io::ErrorKind::Other, + "Failed to get a lock", + )))? .send(strip::Message::ChangePattern(Box::new( // pattern::Solid::new(Rgb::from_str(¶ms.color).or(Err(io::Error::new(io::ErrorKind::Other, "Failed to parse")))?), - pattern + pattern, ))) - .or(Err(io::Error::new(io::ErrorKind::Other, "Failed to send to channel")))?; + .or(Err(io::Error::new( + io::ErrorKind::Other, + "Failed to send to channel", + )))?; Ok(format!("{:?}", params)) }