Cargo fmt

This commit is contained in:
Austen Adler 2021-08-09 23:26:10 -04:00
parent bd616e2a1c
commit 38b339bf2a
3 changed files with 20 additions and 10 deletions

View File

@ -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);

View File

@ -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),
}

View File

@ -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<AppState>, params: web::Json<PatternParameters>) -> Result<impl Responder> {
async fn set_color(
data: web::Data<AppState>,
params: web::Json<PatternParameters>,
) -> Result<impl Responder> {
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(&params.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))
}