Cargo fmt
This commit is contained in:
parent
bd616e2a1c
commit
38b339bf2a
@ -1,7 +1,7 @@
|
|||||||
use hex;
|
use hex;
|
||||||
|
use serde::Deserialize;
|
||||||
use std::num::ParseIntError;
|
use std::num::ParseIntError;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use serde::Deserialize;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Deserialize)]
|
#[derive(Copy, Clone, Debug, PartialEq, Deserialize)]
|
||||||
pub struct Rgb(pub u8, pub u8, pub u8);
|
pub struct Rgb(pub u8, pub u8, pub u8);
|
||||||
|
@ -20,11 +20,11 @@ enum PatternParameters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub enum PatternParameters {
|
pub enum PatternParameters {
|
||||||
Collide(Rgb,Rgb,Rgb),
|
Collide(Rgb, Rgb, Rgb),
|
||||||
Fade(Rgb),
|
Fade(Rgb),
|
||||||
MovingPixel(Rgb),
|
MovingPixel(Rgb),
|
||||||
MovingRainbow(u8, bool),
|
MovingRainbow(u8, bool),
|
||||||
Orb(Rgb, u8,u8),
|
Orb(Rgb, u8, u8),
|
||||||
Solid(Rgb),
|
Solid(Rgb),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
src/webui.rs
24
src/webui.rs
@ -2,13 +2,13 @@ use crate::color::Rgb;
|
|||||||
use crate::pattern;
|
use crate::pattern;
|
||||||
use crate::strip;
|
use crate::strip;
|
||||||
use actix_web::web::Form;
|
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 actix_web::error::InternalError;
|
||||||
use rust_embed::RustEmbed;
|
use rust_embed::RustEmbed;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use std::io;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::io;
|
|
||||||
|
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
|
|
||||||
@ -28,18 +28,28 @@ struct AppState {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
#[post("/setcolor")]
|
#[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);
|
println!("{:?}", params);
|
||||||
let pattern = match params.0 {
|
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
|
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(
|
.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::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))
|
Ok(format!("{:?}", params))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user