Use unstable Crate rustfmt option
This commit is contained in:
parent
b5b4bf3b41
commit
fc5403388f
@ -1,2 +1,2 @@
|
|||||||
# unstable_features = true
|
unstable_features = true
|
||||||
# imports_granularity = "Crate"
|
imports_granularity = "Crate"
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
use serde::Deserialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use serde::Serialize;
|
use std::{num::ParseIntError, str::FromStr};
|
||||||
use std::num::ParseIntError;
|
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Serialize, Default)]
|
#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Serialize, Default)]
|
||||||
pub struct Rgb(pub u8, pub u8, pub u8);
|
pub struct Rgb(pub u8, pub u8, pub u8);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use core::any::Any;
|
use core::any::Any;
|
||||||
use std::fmt;
|
use std::{fmt, io};
|
||||||
use std::io;
|
|
||||||
|
|
||||||
pub type ProgramResult<T> = Result<T, ProgramError>;
|
pub type ProgramResult<T> = Result<T, ProgramError>;
|
||||||
|
|
||||||
|
10
src/main.rs
10
src/main.rs
@ -36,10 +36,12 @@ mod template;
|
|||||||
mod ui;
|
mod ui;
|
||||||
mod webui;
|
mod webui;
|
||||||
use errors::{ProgramError, ProgramResult};
|
use errors::{ProgramError, ProgramResult};
|
||||||
use std::io;
|
use std::{
|
||||||
use std::io::Write;
|
io,
|
||||||
use std::sync::mpsc::{channel, Sender};
|
io::Write,
|
||||||
use std::thread;
|
sync::mpsc::{channel, Sender},
|
||||||
|
thread,
|
||||||
|
};
|
||||||
use strip::LedStrip;
|
use strip::LedStrip;
|
||||||
use ui::console_ui_loop;
|
use ui::console_ui_loop;
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use crate::color::Rgb;
|
use crate::color::Rgb;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::vec_deque;
|
use std::collections::vec_deque;
|
||||||
use std::iter;
|
|
||||||
|
|
||||||
pub mod collide;
|
pub mod collide;
|
||||||
pub mod fade;
|
pub mod fade;
|
||||||
@ -66,7 +65,7 @@ impl InputRender for Rgb {
|
|||||||
impl InputRender for Vec<Rgb> {
|
impl InputRender for Vec<Rgb> {
|
||||||
fn render(&self, name: &str, _multi_index: Option<usize>) -> String {
|
fn render(&self, name: &str, _multi_index: Option<usize>) -> String {
|
||||||
self.iter()
|
self.iter()
|
||||||
.chain(iter::once(&Rgb::default()))
|
// .chain(iter::once(&Rgb::default()))
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.fold(String::new(), |acc, (i, c)| {
|
.fold(String::new(), |acc, (i, c)| {
|
||||||
acc + &c.render(name, Some(i)) + "\n"
|
acc + &c.render(name, Some(i)) + "\n"
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use super::{FormRender, InputRender, Pattern};
|
use super::{FormRender, InputRender, Pattern};
|
||||||
use crate::color::{self, Rgb};
|
use crate::color::{self, Rgb};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::vec_deque;
|
use std::collections::{vec_deque, VecDeque};
|
||||||
use std::collections::VecDeque;
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
pub struct CollideParams {
|
pub struct CollideParams {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use super::{FormRender, InputRender, Pattern};
|
use super::{FormRender, InputRender, Pattern};
|
||||||
use crate::color::{self, merge_colors_u8, Rgb};
|
use crate::color::{self, merge_colors_u8, Rgb};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::vec_deque;
|
use std::{
|
||||||
use std::collections::VecDeque;
|
collections::{vec_deque, VecDeque},
|
||||||
use std::iter;
|
iter,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
pub struct FadeParams {
|
pub struct FadeParams {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use super::{FormRender, InputRender, Pattern};
|
use super::{FormRender, InputRender, Pattern};
|
||||||
use crate::color::{self, Rgb};
|
use crate::color::{self, Rgb};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::vec_deque;
|
use std::collections::{vec_deque, VecDeque};
|
||||||
use std::collections::VecDeque;
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
pub struct MovingPixelParams {
|
pub struct MovingPixelParams {
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
use super::{FormRender, InputRender, Pattern};
|
use super::{FormRender, InputRender, Pattern};
|
||||||
use crate::color::{self, Rgb, RAINBOW};
|
use crate::color::{self, Rgb, RAINBOW};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::{vec_deque, VecDeque};
|
use std::{
|
||||||
use std::convert::TryFrom;
|
collections::{vec_deque, VecDeque},
|
||||||
use std::iter;
|
convert::TryFrom,
|
||||||
|
iter,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
pub struct MovingRainbowParams {
|
pub struct MovingRainbowParams {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use super::{FormRender, InputRender, Pattern};
|
use super::{FormRender, InputRender, Pattern};
|
||||||
use crate::color::{self, Rgb};
|
use crate::color::{self, Rgb};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::vec_deque;
|
use std::{
|
||||||
use std::collections::VecDeque;
|
collections::{vec_deque, VecDeque},
|
||||||
use std::iter;
|
iter,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
pub struct OrbParams {
|
pub struct OrbParams {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use super::{FormRender, InputRender, Pattern};
|
use super::{FormRender, InputRender, Pattern};
|
||||||
use crate::color::{self, Rgb};
|
use crate::color::{self, Rgb};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::vec_deque;
|
use std::collections::{vec_deque, VecDeque};
|
||||||
use std::collections::VecDeque;
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
pub struct SolidParams {
|
pub struct SolidParams {
|
||||||
|
25
src/strip.rs
25
src/strip.rs
@ -1,14 +1,17 @@
|
|||||||
use crate::color;
|
use crate::{
|
||||||
use crate::errors;
|
color, errors,
|
||||||
use crate::errors::ProgramError;
|
errors::ProgramError,
|
||||||
use crate::pattern::{self, Pattern};
|
pattern::{self, Pattern},
|
||||||
use std::cmp;
|
};
|
||||||
use std::ops::Add;
|
use std::{
|
||||||
use std::process;
|
cmp,
|
||||||
use std::sync::mpsc::{Receiver, Sender};
|
ops::Add,
|
||||||
use std::time::{Duration, Instant};
|
process,
|
||||||
use ws2818_rgb_led_spi_driver::adapter_gen::Ws28xxAdapter;
|
sync::mpsc::{Receiver, Sender},
|
||||||
use ws2818_rgb_led_spi_driver::adapter_spi::Ws28xxSpiAdapter;
|
thread,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
use ws2818_rgb_led_spi_driver::{adapter_gen::Ws28xxAdapter, adapter_spi::Ws28xxSpiAdapter};
|
||||||
|
|
||||||
/// Maximum number of lights allowed
|
/// Maximum number of lights allowed
|
||||||
const MAX_NUM_LIGHTS: u16 = 128;
|
const MAX_NUM_LIGHTS: u16 = 128;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
use crate::pattern::{FormRender, Parameters};
|
use crate::{
|
||||||
use crate::strip;
|
pattern::{FormRender, Parameters},
|
||||||
|
strip,
|
||||||
|
};
|
||||||
use std::sync::{mpsc::Sender, Arc, Mutex};
|
use std::sync::{mpsc::Sender, Arc, Mutex};
|
||||||
|
|
||||||
#[derive(askama::Template, Clone, Debug, Default)]
|
#[derive(askama::Template, Clone, Debug, Default)]
|
||||||
|
14
src/ui.rs
14
src/ui.rs
@ -1,10 +1,10 @@
|
|||||||
use crate::color::Rgb;
|
use crate::{
|
||||||
use crate::errors::{self, ProgramError, ProgramResult};
|
color::Rgb,
|
||||||
use crate::pattern::{self, Pattern};
|
errors::{self, ProgramError, ProgramResult},
|
||||||
use crate::strip;
|
pattern::{self, Pattern},
|
||||||
use std::io;
|
strip,
|
||||||
use std::io::Write;
|
};
|
||||||
use std::sync::mpsc::Sender;
|
use std::{io, io::Write, sync::mpsc::Sender};
|
||||||
|
|
||||||
pub fn console_ui_loop(
|
pub fn console_ui_loop(
|
||||||
message_tx: &Sender<errors::Message>,
|
message_tx: &Sender<errors::Message>,
|
||||||
|
17
src/webui.rs
17
src/webui.rs
@ -1,20 +1,21 @@
|
|||||||
use crate::errors;
|
use crate::{
|
||||||
use crate::pattern;
|
errors, pattern, strip,
|
||||||
use crate::strip;
|
template::{AppTemplate, ControlTemplate},
|
||||||
use crate::template::{AppTemplate, ControlTemplate};
|
};
|
||||||
use actix_web::HttpResponse;
|
use actix_web::HttpResponse;
|
||||||
use actix_web_actors::ws;
|
use actix_web_actors::ws;
|
||||||
use live_view::{LiveView, StateSocket, Template};
|
use live_view::{LiveView, StateSocket, Template};
|
||||||
|
|
||||||
use actix_web::HttpRequest;
|
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
error::{ErrorInternalServerError, JsonPayloadError, UrlencodedError},
|
error::{ErrorInternalServerError, JsonPayloadError, UrlencodedError},
|
||||||
get, post, web,
|
get, post, web,
|
||||||
web::JsonConfig,
|
web::JsonConfig,
|
||||||
App, HttpServer, Responder, Result,
|
App, HttpRequest, HttpServer, Responder, Result,
|
||||||
|
};
|
||||||
|
use std::{
|
||||||
|
io,
|
||||||
|
sync::{mpsc::Sender, Arc, Mutex},
|
||||||
};
|
};
|
||||||
use std::io;
|
|
||||||
use std::sync::{mpsc::Sender, Arc, Mutex};
|
|
||||||
|
|
||||||
struct AppState {
|
struct AppState {
|
||||||
strip_tx: Arc<Mutex<Sender<strip::Message>>>,
|
strip_tx: Arc<Mutex<Sender<strip::Message>>>,
|
||||||
|
Loading…
Reference in New Issue
Block a user